﻿/*!
 * 远光ECP平台3.4版本
 * 树表格控件： qzz.ui.qzz
 * ecp.qzz.ui.querygrid.js
 * ecp按钮与菜单控件命名空间
 * @name qzz.ui
 * @namespace qzz.ui
 * @requires qzz.ui.Frame
 * mdf qinzhenzhou222
 */
define(["qzz.frame","qzz.treedataset","qzz.button","qzz.pmenu","qzz.pfilter", "qzz.paged","qzz.coldesign","qzz.icheckbox"], function() {
	
	var qzz = window.qzz;
	qzz.space("ui");
	/**
	 * 树表格控件.		
	 @class qzz 表格类 

	 @extends qzz.ui.Frame
	 @property {number} rowCount 行数
	 @property {number} colCount 列数
	 @property {number} titleRowCount 标题行数
	 @property {number} gridWidth 表格宽度
	 @property {number} gridHeight 表格高度
	 @property {number} colIndex 当前列标
	 @property {boolean} multiSelect 是否复选
     @property {boolean} virtual 是否懒加载
     @property {qzz.TreeDataSet} dataSet 数据模型
     
	 @example
	     var grid = new qzz.ui.qzz(control, option);
	 @author qinzhenzhou@ygsoft.com
	 @version 1.0
	 @date 2014-5-29
	
	 */
	qzz.ui.querygrid = qzz.Class(qzz.ui.frame, 
	/**@lends qzz.ui.qzz# */
	{
		/**
		 * 创建.
		 */
		_create:function() {
			//debugger;
			this.base();
		    this.className = "QueryGrid";
		    this.logBegin("QueryGrid.create");
		    this.container = null;
		    //单元格列表.
		    this.sheets = [];
		    //行高
		    this.rowHeight = 36;
		    //标题行数
		    this.titleRowCount = 0;
		    //列数
		    this.colCount = 0;
		    //显示行数
		    this.rowCount = 0;
		    //分页明细总数
		    this.allCount = 0;
		    //表宽高
		    this.gridWidth = 0;
		    this.gridHeight = 0;
		    //表元素
		    this.gridTable = null;
		    //显示顶节点
		    this.topNode = null;
		    //顶序号
		    this.topIndex = 0;
		    //可能节点数量
		    this.visibleCount = 0;
		    //当前列序号
		    this.colIndex = 1;
		    //区域选择区
		    this.selRect = {"beginRowNode":null,"endRowNode":null,"beginColIndex":1,"endColIndex":1};
		    //
		    this._selRect = {};
		    
		    this._curNode = null;
		    
		    this._addNew = false;
		    
		    this._editTypes = {};
		    //是选择状态
		    this.isSelect = true;
		    //渲染状态
		    this.rendered = false;
		    //鼠标在标题区按下状态
		    this.titleMouseDown = false;
		    //数据模型
		    this.dataSet = new qzz.treedataset();
		    //字段名
		    this.dataSet.setName(this.getName());
		    //复选择标志.
		    this.multiSelect = false;
		    //懒加载配置.
		    this.virtual = false;
		    //编辑状态属性
		    this.dataPost = true;
		    //是否拖动横向滚动条
		    this.scrollMouseDown = false;
		    //单元列
		    this.radioCheck = {};
		    if(this.getOption().totalRever === true) {
		    	//合计
			    this.summaryText = this.getI18n("qzz.pageSummary", "小计：");
			    
			    this.subtotalText = this.getI18n("qzz.summary", "合计：");
		    } else {
			    //合计
			    this.summaryText = this.getI18n("qzz.summary", "合计：");
			    
			    this.subtotalText = this.getI18n("qzz.pageSummary", "小计：");
		    }
		    //序号
		    this.numberCaption = this.getI18n("qzz.index", "序号");
		    //排序列表
		    this.sortTables = {};
		    //当处在单元格编辑时再次点击的状态
			this.mouseEdit = false;
			
			this._setTimeoutStack = {};
		    //设置数据源
		    this.dataSet.open();
		    this.logEnd("TreeDataGrid.create");
		    if(this.dataSet.onChanged == null) {
		    	var _this = this;		    	
		    	this.dataSet.onChanged = function(sender) {
		    		_this.logInfo("row changed event");
		    		if(_this.hasbind("rowChanged")) {
		    			_this.trigger("rowChanged", [sender]);
		    		}
		    		if(typeof _this.onRowChanged == "function") {
		    			try {
		    			    _this.onRowChanged(sender);
		    			} catch(e) {
		    				_this.logInfo("onRowChanged event fire error!");
		    			}
		    		}
		    		_this.trigger("onRowChanged", [sender]);
		    	}
		    }
		    //事件列表
		    this._eventMethods = {
		    		
		    }
	    },

	    /**
	     * 渲染.
	     */
	    _render:function() {
	    	var tabGrid;
	    	if(this.isNotEmpty(this.control) && this.control.length > 0) {
	    		tabGrid = this.control[0]
	    	} else {
	    		tabGrid = this.createElement("table");
	    		this.control = $(tabGrid);
	    	};
	    	var parent = this.control.parent();
	    	this.thisWindow = this.createElement("DIV");
	    	this.setStyle(this.thisWindow, "winStyle");
	    	if(parent != null && parent.length > 0) {
				var di = -1;
				for(var i = 0, len = parent[0].childNodes.length; i < len; i++) {
					if(parent[0].childNodes[i] === tabGrid) {
						di = i; 
						break;
					}
				}
				if(di >= 0) {
				    parent[0].insertBefore(this.thisWindow, parent[0].childNodes[di]);
				} else {
					parent.append(this.thisWindow);
				}
	    	}
	    	
	    	this._initOption();
	    	this.dataSet.reverGJ = this.getOption().reverGJ;
	    	this.dataSet.sumAllLevel = this.getOption().sumAllLevel;
	    	this.dataSet.defSelect = this.getOption().defSelect;
	    	//设置宽度.
	    	if(this.getAlign() != "alClient" 
	    		&& (this.getOption().autoEcpWidth || this.getOption().width == null 
	    				|| this.getOption().width === 10)) {
	    	    this.getOption().width = parent.width();
	    	} else {
	    		this.getOption().width = this._getNumberValue(this.getOption().width, this.getOption().width);
	    	}
	    	if(this.getOption().width <= 0) {
	    		if(this.getOption().width != 10) {
	    			this.getOption().width = this.getOption().width;
	    		} else {
	    		    this.getOption().width = 40;
	    		}
	    	}	    	
	    	//设置高度.
	    	if(this.getAlign() != "alClient" && parent.height() > 10
	    		&& (this.getOption().autoEcpHeight || this.getOption().height == null
	    				|| this.getOption().height === 10)) {
	    		this.getOption().height = parent.height();
	    	} else {
	    		if(this.getOption().height <= 0) {
		    		this.getOption().height = 200;
		    	}
	    		this.getOption().height = this._getNumberValue(this.getOption().height, this.getOption().height);
	    	}   
    		if(this.getOption().height < 30) {
    			this.getOption().height = 30;
    		}
	    	//复选择
	    	if(this.isNotEmpty(this.getOption().multiselect)) {
	    		this.multiSelect = this.getOption().multiselect;
	    		this.dataSet.setMultiSelect(this.multiSelect);
	    	} else if(this.getOption().multiSelect != null) {
	    		this.multiSelect = this.getOption().multiSelect;
	    		this.dataSet.setMultiSelect(this.multiSelect);
	    	}
	    	//选择
	    	if(this.isNotEmpty(this.getOption().checkFlag)) {
	    		var cps = this.getOption().checkFlag;
	    		if(cps.indexOf("p") >= 0) {
	    			this.dataSet.autoCheckType.autoCheckAllParent = true;
	    		}
	    		if(cps.indexOf("s") >= 0) {
	    			this.dataSet.autoCheckType.autoCheckAllChild = true;
	    		}
	    		if(cps.indexOf("b") >= 0) {
	    			this.dataSet.autoCheckType.autoCheckBrother = true;
	    		}
	    		if(cps.indexOf("e") >= 0) {
	    			this.dataSet.autoCheckType.autoCheckAllParentExt = true;
	    		}
	    	}
	    	//取消选择
	    	if(this.isNotEmpty(this.getOption().unCheckFlag)) {
	    		var cps = this.getOption().unCheckFlag;
	    		if(cps.indexOf("p") >= 0) {
	    			this.dataSet.autoCheckType.autoUnCheckAllParent = true;
	    		}
	    		if(cps.indexOf("s") >= 0) {
	    			this.dataSet.autoCheckType.autoUnCheckAllChild = true;
	    		}
	    		if(cps.indexOf("b") >= 0) {
	    			this.dataSet.autoCheckType.autoUnCheckBrother = true;
	    		}
	    		if(cps.indexOf("e") >= 0) {
	    			this.dataSet.autoCheckType.autoUnCheckAllParentExt = true;
	    		}
	    	}
	    	//设置名称
	    	var dfs = this.control.attr("dataField");
	    	if(dfs != null && dfs !== "") {
	    	    this.setName(dfs);
	    	}
	    	//this.name = this.control.attr("dataField");
	    	if(this.isNotEmpty(this.getName())) {
	    		this.dataSet.setName(this.getName());
	    	}
	    	this.dataSet.keyName = this.getPKeyName();
	    	this.dataSet.itemCode = this.dataSet.keyName;
	    	this.base();
	    	this.logBegin("TreeDataGrid.render");
	        //表格
	        this.gridTable = tabGrid;	
	        this.setStyle(this.gridTable, "treeListGrid");
	        
	        this.sumTable = this.createElement("table");
	        this.setStyle(this.sumTable, ["treeListGrid","footerRow"]);
	        var bottomHeight = this.rowHeight;
	        if(this.getOption().pager) {
	        	this._pageBoxHeight = 30;
	        	if(this._pageBoxHeight < this.rowHeight) {
	        		this._pageBoxHeight = this.rowHeight;
	        	}
	        	bottomHeight += this._pageBoxHeight;
	        }
	        this.sumTable.style.bottom = bottomHeight + "px";
	        
	        if(!this.getBrowser("msie")) {
	            this.gridTable.style.tableLayout = "fixed";
	            this.sumTable.style.tableLayout = "fixed";
	        }
	        //控制选择事件
	        this.gridTable.onselectstart = this._onselectstart;
	        //控制右键菜单
	        this.gridTable.oncontextmenu = function(e) {
	        	return false;
	        }	        
	        //控制选择事件
	        this.sumTable.onselectstart = this._onselectstart;
	        //控制冻结
	        this.sumTable.oncontextmenu = function(e) {
	        	return false;
	        }
	        //开启服务端分页.
	        this._initPagerBox();
	        //冻结列
	        fzGridDiv = this.createElement("DIV");
	        this.fzGridSheetsDiv = fzGridDiv;
	        this.setStyle(fzGridDiv, "fixDiv");	        
	        this.fzGridTable = this.createElement("table");
	        this.fzGridTable.style.top = "0px";
	        this.setStyle(this.fzGridTable, "treeListGrid");
	        //冻结列合计行
	        this.fzSumTable = this.createElement("table");
	        this.setStyle(this.fzSumTable, ["treeListGrid","fzFooterRow"]);
	        if(!this.getBrowser("msie")) { 
	            this.fzGridTable.style.tableLayout = "fixed";
	            this.fzSumTable.style.tableLayout = "fixed";
	        }
	        
	        //控制选择事件
	        this.fzGridTable.onselectstart = this._onselectstart;
	        //控制冻结
	        this.fzGridTable.oncontextmenu = function(e) {
	        	return false;
	        }
	        //控制选择事件
	        this.fzSumTable.onselectstart = this._onselectstart;
	        //控制冻结
	        this.fzSumTable.oncontextmenu = function(e) {
	        	return false;
	        }
	        
	        fzGridDiv.appendChild(this.fzGridTable);
	        fzGridDiv.appendChild(this.fzSumTable);
	        this.mainbox.appendChild(fzGridDiv);	
	        
	       	this.emptyDiv = this.createElement("DIV");
	        this._setHtml(this.emptyDiv, this.getI18n("qzz.emptyRecord", "<没有任何记录>"));
	        this.setStyle(this.emptyDiv, "fixDiv");
	        this.mainbox.appendChild(this.emptyDiv);
	        this.emptyDiv.style.color = "#ACA899";
	        //保存默认状态
	        if(this.option.defColNames == null) {	        	
	    		this.option.defColNames = this.extend([],this.option.colNames);
	    		this.option.defColModels = this.extend([],this.option.colModels);
	        }
	        //如果配置了保存格式主键，则调用服务端的接口获得配置序列
	        if(this.getOption().columnSetupId != null) {
	    		var hres = this.findColumnSetup();
	    		//保存默认状态
//	    		this.option.defColNames = this.option.colNames;
//	    		this.option.defColModels = this.option.colModels;
	    		if(this.isNotEmpty(hres)) {
	    			hres = $.parseJson(hres);
	    		    if(this.isNotEmpty(hres["colNames"])) {
	    		    	this.option.colNames = hres["colNames"];
	    		    }
	    		    if(this.isNotEmpty(hres["colModels"])) {
	    		    	this.option.colModels = hres["colModels"];
	    		    }
	    		}
	        }
	        //初始化colModels
	        this._initColModel();
	        //解析与创建表头分离
	        this._parseTitle();
	        this.dataSet.setViewColModels(this.option.colModels);
	        this._createModelJson();
	        
	        this.listDivBox = this.createElement("SPAN");
	        this.setStyle(this.listDivBox,"ListBoxDiv");
	        
	        this.listDivBox.appendChild(this.gridTable);
	        this.listDivBox.appendChild(this.sumTable);
	        this.listDiv.appendChild(this.listDivBox);
	    	this._createTitle();
	        this.initGrid();
	        //兼容处理control对象
	        this.control[0].p = $.extend(true, {}, this.option);
	        this.control[0].p.id = this.control[0].id;
	        this.control[0].p.colNames = this.colNames;
	        this.rendered = true;
	        //添加是否可选择样式.
	        this.addStyle(this.listDiv, "canNotSelect");
	        this.addStyle(fzGridDiv, "canNotSelect");	
	        this.logEnd("TreeDataGrid.render");
	        //复制输入框
	        this.copyDiv = this.createElement("div");
	        this.setStyle(this.copyDiv,"fixDiv");
	        this.copyDiv.style.top = "0px";
	        this.copyDiv.style.left = "0px";
	        this.copyDiv.style.height = "1px";
	        this.copyDiv.style.width = "1px";
	        this.copyInput = this.createElement("textarea");
	        this.setStyle(this.copyInput, "editTextInputer");
	        this.copyInput.style.width="300px";
	        this.copyInput.style.height="300px";
	        this.pasteKeyPress = false;
	        var _this = this;
	        //上一回滚动位置
	        this.priorScrollIndex = 0;
	        //横向滚动的时候，这个距离需要刷新一次.
	        this.scrollWidth = 300;
	        this.listDiv.onscroll = function(ev) {
	        	//横向滚动300px的时候，刷新一下
	        	var len = this.scrollLeft - _this.priorScrollIndex;
	        	if(len < 0) {
	        		len = 0 - len;
	        	}
	        	if(len > _this.scrollWidth + 100) {	 
	        		//刷新
	        		_this.priorScrollIndex = this.scrollLeft;
	        		_this._asynRun(function(){
	        			this.post();
		        		this.refresh(true);
	        		}, 50);
	        	}
	        	_this._hasScroll = true && _this.scrollMouseDown;
	        }
	        //复制按钮事件
	        this.copyInput.onkeydown = function(ev) {
				var ev = ev || window.event;
				if(_this.pasteKeyPress) {
					ev.returnValue = false;
					return false;
				}
			}
	        this.copyDiv.appendChild(this.copyInput);
	        this.fzGridSheetsDiv.appendChild(this.copyDiv);
	        //添加菜单控件
	        this.popMenu = new qzz.ui.drop.popmenu(undefined, {"cssPrefix":this._cssPrefix});
	        this.popMenu.onDrop = function(owner) {
				_this.setBlur();
			};
			this.popMenu.onHide = function(date) {
				_this.setFocus();
			}
	        this.popMenu.setParent(this.getBody());
	        this.popMenu.beginUpdate();
	        //菜单事件列表.
	        if(this.treeGrid != false) {
		        this.popMenu.addMenu("fullcollapse", this.getI18n("qzz.collapse", "全收缩"), function(){
		        	_this.dataSet.fullCollapse(function(){
		        		_this.first();
			        	_this.setFocus();
			        	_this.selRect.beginRowNode = _this.dataSet.getCurNode();
			        	_this.selRect.endRowNode = _this.selRect.beginRowNode;
			        	_this.selRect.beginColIndex = this.colIndex;
			        	_this.selRect.endColIndex = _this.selRect.beginColIndex;
			        	_this.refresh();
		        	});
		        });
		        this.popMenu.addMenu("fullexpand", this.getI18n("qzz.expand", "全展开"), function(){
		        	_this.dataSet.fullExpand();
		        	_this.setFocus();
		        	_this.selRect.beginRowNode = _this.dataSet.getCurNode();
		        	_this.selRect.endRowNode = _this.selRect.beginRowNode;
		        	_this.selRect.beginColIndex = this.colIndex;
		        	_this.selRect.endColIndex = _this.selRect.beginColIndex;
		        	_this.refresh();
		        });		        
	        }	        
	        var mnen = (this.getBrowser("msie") == true)
	        if(mnen) {
	        	if(this.popMenu._popCount > 0) {
	        	    this.popMenu.addMenu("split1", "-");
	        	}
		        //复制事件
		        this.popMenu.addMenu("copy", this.getI18n("qzz.copy", "复制"), function(){
		        	var text = _this.getCopyData();
		        	_this.setFocus();
		        	if(_this.isEmpty(text)) {
		        		var fieldName = _this.getFieldName();
		        		text = _this.dataSet.getDisplay(fieldName, undefined, _this.selRect.beginRowNode);
		        	}
		        	window.clipboardData.setData("text", text);
		        	_this.hasCopy = true
		        	_this.refresh();
		        }, "Ctrl+C", mnen);
	        }
	        //列宽设置
	        if(this.getOption().colDesign
	        	&& qzz != null
	        	&& qzz.pertain != null
	        		&& typeof qzz.pertain.gridcoldesign == "function") {
	        	if(this.popMenu._popCount > 0) {
	        	    this.popMenu.addMenu("split2", "-");
	        	}
	        	this.popMenu.addMenu("qzzFormat", this.getI18n("qzz.colset", "列设置"), function(){
	        		_this.focus = false;
	    			qzz.pertain.gridcoldesign(_this);
		        });	
	        }
	        this.popMenu.endUpdate();
	        this.refresh();
	        if(this.isArray(this.getOption().data)) {
	        	this.value(this.getOption().data);
	        }
	        //初始化筛选过滤窗口.
	        if(this.getOption().filter) {
	        	this._asynRun(function(){this._initFilterWindow();},10);
	        }
	    },
	    //---------------------------------------------private---------------------------------------
	    /**
	     * 初始化，读取属性.
	     * @name _initOption
	     * @ignore
	     */
	    _initOption:function() {
	    	//表格自适应宽度.
	    	this.getOption().autoEcpWidth =  this.getBooleanValue(this.getOption().autoEcpWidth, false);
	    	//表格自适应宽度.
	    	this.getOption().autoEcpHeight =  this.getBooleanValue(this.getOption().autoEcpHeight, false);
	    	//过滤条件
	    	this.getOption().filter = this.getBooleanValue(this.getOption().filter, true);
	    	//填充空白属性.
	    	this.getOption().shrinkToFit = this.getBooleanValue(this.getOption().shrinkToFit, true);
	    	//适应宽度
	    	this.getOption().suitToFit = this.getBooleanValue(this.getOption().suitToFit, false);
	    	//虚拟树属性
	    	this.getOption().virtual = this.getBooleanValue(this.getOption().virtual, false);
	    	//序号列
	    	this.getOption().rownumbers = this.getBooleanValue(this.getOption().rownumbers, true);
	    	//是否树表
	    	this.getOption().treeGrid = this.getBooleanValue(this.getOption().treeGrid, false);
	    	//树表
	    	this.treeGrid = this.getOption().treeGrid;
	    	//列设置
	    	this.getOption().colDesign = this.getBooleanValue(this.getOption().colDesign, true);
	    	//Enter按键控制（预算特需需求）
			this.getOption().EnterDown = this.getBooleanValue(this.getOption().EnterDown, false);
	    	//服务端分页
	    	this.getOption().pager = this.getBooleanValue(this.getOption().pager, false);
	    	//是否合计所有行
	    	this.getOption().sumAllLevel = this.getBooleanValue(this.getOption().sumAllLevel, false);
	    	//设置显示时间
	    	this.getOption().showTime = this.getBooleanValue(this.getOption().showTime, false);
	    	//
//	    	if(this.getOption().primaryKey != null) {
//	    	    this.PKeyName = this.getOption().primaryKey;
//	    	}
	    	//行高配置
	    	this.rowHeight = this._getNumberValue(this.getOption().rowHeight, this.rowHeight);
	    	//反向勾稽
	    	this.getOption().reverGJ = this.getBooleanValue(this.getOption().reverGJ, false);
	    	//树列所在的字段
	    	this.getOption().treeKey = this.getOption().treeKey || this.getOption().treekey;
	    	//添加默认选择配置
	    	this.getOption().defSelect = this.getBooleanValue(this.getOption().defSelect, true);
	    },
	    /**
	     * 初始化分页功能.
	     */
	    _initPagerBox:function() {
	    	if(this.getOption().pager) {
	    		this._pageBoxHeight = 30;
	    		if(this._pageBoxHeight < this.rowHeight) {
	        		this._pageBoxHeight = this.rowHeight;
	        	}
	    		if(this.pageTd == null) {
	    			if(this.frameTable.rows.length < 2) {
	        	        this.pagTd = this.frameTable.insertRow(1).insertCell(0);
	    			} else {
	    				this.pagTd = this.frameTable.rows[1].cells[0];
	    				this._setHtml(this.pagTd, "");
	    			}
	    		} else {
	    			this._setHtml(this.pagTd, "");
	    		}
	        	this.pagTd.setAttribute("colSpan", 2);
	        	this.pagTd.style.height = this._pageBoxHeight + "px";
	        	this.setStyle(this.pagTd, "pageDivLine");
	        	
	        	this.pageObj = new qzz.ui.paged({width:"100%",minPager:this.getOption().minPager,"filterCount":this.getOption().filterCount});
				this.pageObj.setPageSizeList(this.getOption().pageSizeList);
				if(this.getOption().pageSize != null) {
				    this.pageObj.setPageSize(this.getOption().pageSize);
				}
				var _this = this;
				this.pageObj.bind("onPageChanged", function(pc,ps,pi){
					if(_this._update) {
						_this.getOption().pageCount = pc;
						_this.getOption().pageSize = ps;
						_this.getOption().pageIndex = pi;
						_this._loadSerData(pc, ps, pi);
						this.clearFilterCount();
						_this.refresh();
					}
				});
				this.pagTd.style.paddingRight = "8px";
	        	this.pageObj.setParent(this.pagTd);
	    	} else {
	    		this._pageBoxHeight = 0;
	    		if(this.pagTd != null) {
	        	    this.pagTd.style.height = this._pageBoxHeight + "px";
	        	    this._setHtml(this.pagTd, "");
	    		}
	    	}
	    	var h = this._getRectHeight() - this._pageBoxHeight;
	    	if(h < 1) {
	    		h = 1;
	    	}
	    	this.listDiv.style.height = h + "px";
	    },
	    /**
	     * 同步dataField.
	     */
	    setName:function(name) {
	    	this.base(name);
	    	this.dataSet.setName(name);
	    },
	    /**
	     * 首页.
	     * @name firstPage
		 * @example
		 * grid.firstPage();
		 * @author qzz
		 * @version 1.0
		 * @date 2014-6-30	
	     */
	    firstPage:function(fireEvent) {
	    	this.pageObj.firstPage(fireEvent);
	    },
	    /**
	     * 上页.
	     * @name priorPage
		 * @example
		 * grid.priorPage();
		 * @author qzz
		 * @version 1.0
		 * @date 2014-6-30	
	     */
	    priorPage:function() {
	    	this.pageObj.priorPage();
	    },
	    /**
	     * 下页.
	     * @name nextPage
		 * @example
		 * grid.nextPage();
		 * @author qzz
		 * @version 1.0
		 * @date 2014-6-30	
	     */
	    nextPage:function() {
	    	this.pageObj.nextPage();
	    },
	    /**
	     * 尾页.
	     * @name lastPage
		 * @example
		 * grid.lastPage();
		 * @author qzz
		 * @version 1.0
		 * @date 2014-6-30	
	     */	    
	    lastPage:function() {
	    	this.pageObj.lastPage();
	    },
	    /**
	     * 设置每页明细数量.
	     * @name setPageSize
	     * @param {number} size 页面大小
		 * @example
		 * grid.setPageSize(20);
		 * @author qzz
		 * @version 1.0
		 * @date 2014-6-30	
	     */	 
	    setPageSize : function(size, refresh) {
	    	this.pageObj.setPageSize(size, refresh);
	    },
	    /**
	     * 设置数据明细行数.
	     * @name setTotalRecord
	     * @param {number} count 所有数量
		 * @example
		 * grid.setPageCount(46);
		 * @author qzz
		 * @version 1.0
		 * @date 2014-6-30	
	     */	 
	    setTotalRecord : function(count, refresh) {
	    	this.pageObj.setTotalCount(count, refresh);
	    },
	    /**
	     * 设置数据明细行数.
	     * @name setTotalRecord
	     * @param {number} count 所有数量
		 * @example
		 * grid.setPageCount(46);
		 * @author qzz
		 * @version 1.0
		 * @date 2014-6-30	
	     */	
	    setTotalCount : function(count, refresh) {
	    	this.pageObj.setTotalCount(count, refresh);
	    },
	    /**
	     * 设置页面序号.
	     * @name setPageIndex
	     * @param {number} index 页面序号
		 * @example
		 * grid.setPageIndex(5);
		 * @author qzz
		 * @version 1.0
		 * @date 2014-6-30	
	     */	 
	    setPageIndex : function(index, refresh) {
	    	this.pageObj.setPageIndex(index, refresh);
	    },
	    /**
	     * 保存状态还原.
	     * @name resetPageState
	     * @example 
	       var that = this;
	       grid.setTotalRecord(100);
	       grid.onPageChanged = function(count, size, index) {
	          that.rs.IServer.findData(count, size, index, function(resp, textStatus, jqXHR, errorThrown){
					if (errorThrown) {
						$.ecp.dialog(jqXHR.responseText);
						grid.resetPageState();
					} else {
					    //初始化数据					    
					    grid.value(resp.data);
					}
	          });
	       }
	     * @example
	       var that = this;
	       grid.setTotalRecord(900);
	       grid.bind("onPageChanged", function(count, size, index) {
	          that.rs.IServer.findData(count, size, index, function(resp, textStatus, jqXHR, errorThrown){
					if (errorThrown) {
						$.ecp.dialog(jqXHR.responseText);
						grid.resetPageState();
					} else {
					    //初始化数据
					    grid.value(resp.data);
					}
	          });
		 * @author qzz
		 * @version 1.0
		 * @date 2014-6-30	
	     */	
	    resetPageState : function() {
	    	this.pageObj.resetPageState();
	    },
	    /**
	     * 初始化colModels属性.
	     */
	    _initColModel:function(){
	    	this.dataSet.fieldOption = {};
	    	this.dataSet.transIndex ++;
	    	var gridWidth = 0;
	        var cmjs = {};
	        if(this.isArray(this.option.colModels)) {
	        	for(var j = 0, clen = this.option.colModels.length; j < clen; j++) {
	        		var cm = this.option.colModels[j];
	        		if(cm.width != null) {
	        			cm.width = parseInt(cm.width, 10);
		        	    cm.defWidth = cm.width;
	        		} else {
	        			cm.width = 100;
	        		}
		        	cm.colIndex = j;
		        	//解析格式化
		        	if(cm.format != null && cm.format !== ""
		        		&& typeof cm.format == "string" && cm.format.indexOf("{") >= 0) {
		        		var fmtjs = $.evalJSON(cm.format);
		        		var strcode = fmtjs.code;
		        		var strcodeAry = strcode.split("#");
		        		if(strcodeAry[0] == "@percent") {
		        			cm.numUnit = "0.01";
		        			if(!isNaN(strcodeAry[1])) {
		        				cm.dataScale = parseInt(strcodeAry[1], 10);
		        			}
		        			cm.format = null;
		        		} else if(strcodeAry[0] == "@perthoursand") {
		        			cm.numUnit = "0.001";
		        			if(!isNaN(strcodeAry[1])) {
		        				cm.dataScale = parseInt(strcodeAry[1], 10);
		        			}
		        			cm.format = null;
		        		} else if(strcodeAry[0] == "@numerical") {
		        			//折合
		        			var amount = strcodeAry[4];
		        			if(this.notEmpty(amount)) {
		    					var am = $.ecp.constants.AMOUNT;
		    					var amVal = am[amount];
		    					if(amVal != null) {
		    						cm.numUnit = amVal;	    	        			
		    	        			cm.format = null;
		    					}
		    					am = null;
		    				}
		        			if(!isNaN(strcodeAry[1])) {
		        				cm.dataScale = parseInt(strcodeAry[1], 10);
		        			}	        			
		        		}
		        		fmtjs = null;
		        		strcodeAry = null;	        		
		        	} else {
		        		cm.format = "";
		        	}
		        	if(cm.dataType == null && cm.editType === "date") {
	        			cm.dataType = cm.editType;
	        		}		        	
		        	cm.hidden = this.getBooleanValue(cm.hidden, false);
		        	gridWidth += cm.width;
		        	//设置合计行
		        	if(cm.sum) {
		        		this.dataSet.addSumColumn(cm.name);
		        	}
		        	//如果是筛选列，处理一下选择的值
		        	if(cm.editType === "checkBox" || cm.editType === "radio" || cm.editType === "onoff") {
		        		if(this.isEmpty(cm.editoptions)) {
		        			if(cm.isCheck != null || cm.unCheck != null) {
		        				cm.editoptions = {"check":cm.isCheck,"uncheck":cm.unCheck};
		        			} else {
		        			    cm.editoptions = {"check":true,"uncheck":false};
		        			}
		        		} else {
		        			var chkAry = [];
		        			if(cm.editoptions.value != null) {
		        			    chkAry = cm.editoptions.value.split(":");
		        		    }
		        			if(chkAry.length > 1) {
		        			    cm.editoptions = {"check":chkAry[0],"uncheck":chkAry[1],"value":cm.editoptions.value};
		        			} else {
		        				cm.editoptions = {"check":true,"uncheck":false};
		        			}
		        		}
		        	}
		        	//td 上设置有data的时候.
		        	if(this.isNotEmpty(cm.data)) {
		        		var datas = cm.data;
		        		var transIDName = {};
		        		//处理有初始化数组列
		        		if(this.isArray(datas)) {	        			
		        			if(datas.length > 0 && this.isNotEmpty(datas[0].id) && this.isNotEmpty(datas[0].text)){
		        				var idn = {};
			        			for(var mti = 0, mtlen = datas.length; mti < mtlen; mti++) {
			        				idn[datas[mti].id] = datas[mti].text;
			        			}
			        			transIDName[cm.name] = idn;
			        			idn = null;
			        		}	        			
		        		} else if(typeof datas == "object") {
		        			transIDName[cm.name] = idn;
		        		}
		        		//初始化到转换列表中.
		    	    	this.dataSet.setTransIDName(cm.name, transIDName[cm.name]);
		    	    	transIDName = null;  	        		
		        	} //if cm.data
		        	//重新赋值.
		        	this.option.colModels[j] = cm || {};
		        } //for j
	        } //if colModels
	        this.option.gridWidth = gridWidth;
	    },
	    /**
	     * 解析表头.
	     * @param 传入表头字符串
	     */
	    _parseTitle:function() {
	        //清除表头空行	        
	        var titleSheets = [];	        
	        var rlen = 1, clen = 1, colnames = [];
	        if(this.option.colNames[0] instanceof Array) {
	        	rlen = this.option.colNames.length;
	        	if(this.option.colNames[rlen - 1] != null) {
	        		clen = this.option.colNames[rlen - 1].length;
	        	} else {
	        		clen = this.option.colNames[rlen - 2].length;
	        		rlen --;
	        	}
	        	colnames = this.option.colNames;
	        } else {
	        	clen = this.option.colNames.length;
	        	colnames = [this.option.colNames];
	        }	        
	        var titleRowCount = rlen + 1;
	        var colCount = clen + 1; 
	        //生成表格层次关系
	        for(var i = 1; i <= rlen; i++) {
	        	titleSheets[i] = [];
	        }
	        var colModel = this.option.colModels;
	        for(var i = rlen - 1; i >= 0; i--) {
	        	var grow = colnames[i];
	        	var glen = grow.length;
	        	for(var j = 0, k = 0; j < clen; j++) {
	        		var gcol = null;
	        		var cc = grow[k];
        			if(typeof cc == "string") {
        				cc = {"caption":cc};
        				if(i < rlen - 1) {
        					cc.startIndex = j;
        					cc.colSpan = clen;
        				}
        			}
	        		if(k < glen) {
	        			//获取多表头的起始列字段	        			
		        		var stIndex = cc.startIndex;
		        		//如果有起始列字段名
		        		if(stIndex === 0 || stIndex != null) {
		        			//如果名存在则返回列对象
		        			if(stIndex == j) {
		        				gcol = cc;
		        				gcol.isBand = true;
		        				k++;
		        			}
		        			//else 为空则不处理
		        		} else {
		        			//没有则直接返回列,字段列的时候会直接返回当前cell
		        			gcol = cc;
		        			k++;
		        			if((gcol.caption == null || gcol.caption === "") && i < rlen - 1) {
		        				gcol = null;
		        				this.logInfo(this.getI18n("qzz.mergCell", "合并空的单元格"));
		        				//k--;
		        			}		        			
		        		}
	        		}	        		
	        		//如果列对象存在
	        		if(this.isEmpty(gcol)) {
	        			//缓存到titleSheets中
	        			if(i < rlen - 1) {
	        				titleSheets[i + 1][j] = titleSheets[i + 2][j];
	        				var ts = titleSheets[i + 1][j];
	        				if(ts.colIndex == j) {
	        					ts.rowspan ++;
	        				}	        				    
	        				ts.rowIndex = i + 1;
	        			}
	        		} else {
	        			//作为合并列处理，
	        			var ts = {};
	        			titleSheets[i + 1][j] = ts;
	        			var caption = gcol.caption;
	        			if(colModel[j].caption == null) {
	        			    colModel[j].caption = caption;
	        			}
	        			ts.caption = caption;
	        			ts.rowspan = 1;
	        			ts.rowIndex = i+1;
	        			ts.colIndex = j;
	        			ts.isBand = gcol.isBand || false;
	        		    var colspan = gcol.colSpan;
	        			if(this.isNotEmpty(colspan) && parseInt(colspan, 10) > 1) {
	        				ts.colspan = parseInt(colspan, 10);
	        				var colLen = ts.colspan + j;
	        				j++;
	        				for(;j < clen && j < colLen; j++) {
	        					titleSheets[i + 1][j] = ts;
	        				}
	        				j --;
	        			}
	        		    ts = null;
	        		}
	        		gcol = null;
	        	}
	        	grow = null;
	        }
	        this.option.titleSheets = titleSheets;
	        this.option.titleRowCount = titleRowCount;
	        this.option.colCount = colCount;
	    },
	    
	    _createModelJson:function() {
	    	this.option.colModelJson = {};
	        for(var i = 0, len = this.option.colModels.length; i < len; i++) {
	        	var cm = this.option.colModels[i];
	        	cm._defWidth = cm.width;
	        	this.option.colModelJson[cm.name] = cm;
	        }	        
	    },
	    /**
	     * 获取行高.
	     * @name _addDeff
	     * @ignore
	     */
	    _addDeff:function(value) {
	    	if(value == null) {
	    		value = 0;
	    	}
	    	if(this.getBrowser("msie")) {
	    		return 0;
	    	} else {
	    		return value;
	    	}
	    },
	    /**
	     * 列表偏差.
	     * @name _colIndexDeff
	     * @ignore
	     */
	    _colIndexDeff:function() {
	    	if(this._hasCheckCol) {
	    		return 1;
	    	} else {
	    		return 0;
	    	}
	    },
	    /**
	     * 初始化标题事件.
	     * @name _initTitleEvent
	     * @ignore
	     */
	    _initTitleEvent:function(col) {
	    	var _this = this;
	    	col.onmouseover = function(ev) {
				var ev = ev || window.event;
				_this.doTitleMouseOver(this, ev);
			}
	    	col.onmousemove = function(ev) {
				var ev = ev || window.event;
				_this.doTitleMouseMove(this, ev);
			}
	    	col.onmousedown = function(ev) {
				var ev = ev || window.event;
				_this.doTitleMouseDown(this, ev);
			}
	    	col.onmouseup = function(ev) {
				var ev = ev || window.event;
				_this.doTitleMouseUp(this, ev);
			}
	    	col.ondblclick = function(ev) {
	    		var ev = ev || window.event;
	    		_this.doTitleDBClick(this, ev);
	    	}
	    },
	    _doTitleCheck:function(checkBox, fieldName) {
	    	this.sortClick = true;
	    	this.post();
	    	var grid = this;
	    	var state = checkBox.getCheck();
			if(state === false) {
				this.cancelSelectRow(fieldName, false, function() {						
					grid.refresh();
					grid.trigger("onSelectAll", [state, fieldName]);
					grid.trigger("onCheckAll", [state, fieldName]);
				});
			} else {
				grid.selectAll(fieldName, false, function() {
					grid.refresh();
					grid.trigger("onSelectAll", [state, fieldName]);
					grid.trigger("onCheckAll", [state, fieldName]);
				});
			}
	    },
	    /**
	     * 初始化表头复选择框.
	     * @name _initTitleCheckBox
	     * @ignore
	     */
	    _initTitleCheckBox:function(col, fieldName, cm) {
	    	//col.checkBox = this.createElement("input");
	    	col.checkBox = new qzz.ui.input.checkbox();
	    	//col.checkBox.type = "checkbox";
	    	//this.setStyle(col.checkBox, "checkBox");
	    	//col.checkBox.style.marginRight = "4px";
	    	col.checkBox.fieldName = fieldName;
			var grid = this;
			col.checkBox.bind("onClick", function() {
			//col.checkBox.onmouseup = function(ev) {
		    //col.checkBox.click = function(ev) {
				grid._doTitleCheck(this, this.fieldName);
			}, true);
			if(col.childNodes.length > 0) {
			    col.insertBefore(col.checkBox.getContainer(), col.childNodes[0]);
			} else {
				col.appendChild(col.checkBox.getContainer());
			}
			if(this._checkBoxs == null) {
			    this._checkBoxs = {};
			}
			if(fieldName ==  null || fieldName === "") {
			    fieldName = "@MUL";
			}
			this._checkBoxs[fieldName] = col.checkBox;
			
			if(cm != null && cm.editType == "onoff") {
				col.checkBox.onoff = new qzz.ui.button({"move":true, "width":40,"height":22,"common":["onoff_off", "onoff_on"]});
				col.checkBox.hide();
                var cct = col.checkBox.onoff.getContainer();
                cct.style.margin = "auto";
				if(col.childNodes.length > 0) {
				    col.insertBefore(cct, col.childNodes[0]);
				} else {
					col.appendChild(cct);
				}				
				col.checkBox.onoff.bind("onclick",col.checkBox, function(checkBox, ev){
					grid._doTitleCheck(checkBox, checkBox.fieldName);
					checkBox.setCheck(this._stateValue === 1);
					this.focus = false;
				});
			}			
	    },
	    /**
	     * 重构表头.
	     */
	    _createTitle:function() {
			var tabMainGrid = this.gridTable;
			var titleSheets = this.option["titleSheets"];
			var colModel = this.option["colModels"];
	    	this.colModels = {};
	    	this.gridWidth = this.option.gridWidth;
	    	this.titleRowCount = this.option.titleRowCount;
	    	this.colCount = this.option.colCount;
			var clen = this.colCount - 1;
			var rlen = this.titleRowCount - 1;
			//清除原来所有内容
			while(tabMainGrid.rows.length > 0) {
				tabMainGrid.deleteRow(0);
			}
			//冻结列清空
			while(this.fzGridTable.rows.length > 0) {
				this.fzGridTable.deleteRow(0);
			}
			//重新创建表格层次结构
			var fzRow, fzCol;
			var mgRow = tabMainGrid.insertRow(0);
			var fzRow = this.fzGridTable.insertRow(0);
			var isFrozen = true;
			this.fzColCount = 1;
			//插入顶层行
			for(var i = 0; i < clen; i++) {
				var cm = colModel[i];
				mgCol = mgRow.insertCell(i);
				mgCol.style.height = "1px";
				mgCol.style.width = cm.width + "px";
				mgCol.option = {"colModel":cm,"defWidth":cm.width,"cIndex":i};
				isFrozen = isFrozen && cm.frozen || false;
				if(isFrozen) {
					this.fzColCount ++;
					fzCol = fzRow.insertCell(i);
					fzCol.style.height = "1px";
					fzCol.style.width = cm.width + "px";
					fzCol.option = {"colModel":cm,"defWidth":cm.width,"cIndex":i};
					mgCol.option.fzCol = fzCol;
				}
			}
			//print header
			this.header = [];
			this.titleCol = [];
			this.colNames = [];
			var _this = this;
			//插入所有可见表格col元素
			for(var i = 1; i <= rlen; i++) {
				mgRow = tabMainGrid.insertRow(i);
				fzRow = this.fzGridTable.insertRow(i);
				var isFrozen = true;
				this.header[i - 1] = [];
				for(var j = 0, k = 0; j < clen; j ++) {	
					var tst = titleSheets[i][j];					
					if(this.isNotEmpty(tst) && tst.rowIndex == i && tst.colIndex == j) {
						//多行的时候，只需要当前行设置一下
						tst.cellIndex = k;
						//符合创建元素
						mgCol = mgRow.insertCell(k);
						//指向自定义属性
						mgCol.option = {};
						//指向自定义dom元素
						mgCol.dom = {};
						if(i > 1) {		
							var ptst = titleSheets[i - 1][j];
							if(ptst.rowIndex != i - 1) {
								ptst = titleSheets[ptst.rowIndex][j];
							}
						    mgCol.option.bandColIndex = ptst.cellIndex;
						    mgCol.option.bandRowIndex = ptst.rowIndex;
						}
						mgCol.option.cIndex = j;
						//添加事件
						this._initTitleEvent(mgCol);
						this.setStyle(mgCol, "treeListTitle");
						this._setHtml(mgCol, tst.caption, false);
						//生成表头信息
						this.header[i - 1][k] = {
						    "text":tst.caption,
			                "colFrom":j,
			                "colTo":j,
			                "rowFrom":i-1,
			                "rowTo":i-1
			            };
						var colspan = tst.colspan;
						var cm = colModel[j];
						isFrozen = isFrozen && cm.frozen || false;
						if(this.isNotEmpty(colspan) && colspan > 1) {
							//处理固定列，表头被拆分状态
							var incs = colspan;
							if(isFrozen) {
			    				var csIndex = 1;
			    				for(; csIndex < incs; csIndex++) {
			    					var ipr = colModel[csIndex + j];
			    					if(ipr.frozen != true) {
			    						break;
			    					}
			    				}
			    				if(csIndex < incs) {
			    					//插入新col元素
			    					for(var rsIndex = i; rsIndex <= rlen; rsIndex++) {
			    						var ctst = titleSheets[rsIndex][j + csIndex];
			    						if(ctst.colIndex != j + csIndex) {
			    						    //表头信息
			    							ctst =  {"caption":ctst.caption,
			        				            "colspan":ctst.colspan - (j - ctst.colIndex  + csIndex),
			        				            "colIndex":j + csIndex,
			        				            "rowspan":ctst.rowspan,
			        				            "rowIndex":ctst.rowIndex,
			        				            "isBand":ctst.isBand,
			        				            "cellIndex":ctst.cellIndex + 1
			        				        };
			        				        titleSheets[rsIndex][j + csIndex] = ctst;
			        				        //更新后续的表头信息
			        				        for(var asIndex = 1; asIndex < ctst.colspan; asIndex ++) {
			        				        	titleSheets[rsIndex][ctst.colIndex + asIndex] = ctst;
			        				        }
			    						}
			    						ctst = null;
			    					}
			    					incs = j + csIndex - tst.colIndex;
			    				}
			    				mgCol.style.borderRight = "1px solid #C3D2E6";
							}
							mgCol.setAttribute("colSpan", incs);
							mgCol.option.fieldNames = [cm.name];
							this.header[i - 1][k].colTo += incs - 1;
							//多列时，后续列要设置cellIndex
							for(var csi = j + 1; csi < j + incs; csi++) {
								titleSheets[i][csi].cellIndex = k;
								mgCol.option.fieldNames.push(colModel[csi].name);
							}
							j += incs - 1;
						} else {
							this.colNames.push(tst.caption);
							//单列时，直接处理信息。
							mgCol.setAttribute("colSpan", 1);
							mgCol.option.fieldNames = [cm.name];
							if(this.isNotEmpty(cm)) {
								if(this.isNotEmpty(cm.numUnit) && parseFloat(cm.numUnit,10) > 1) {
									mgCol.setAttribute("title", "×" + this.numberFormat(cm.numUnit));
								} else if(this.isNotEmpty(cm.option)){
									if(this.isNotEmpty(cm.minDate)) {
										mgCol.setAttribute("title", this.getI18n("qzz.minDate", "最小日期：") + cm.minDate + "\n");
									}
									if(this.isNotEmpty(cm.maxDate)) {
										mgCol.setAttribute("title", mgCol.getAttribute("title") + this.getI18n("qzz.maxDate", "最大日期：") + cm.maxDate);
									}
								}
			    			}
//							if(cm.editType == "checkBox" && cm.selectAll == true && tst.isBand != true) {
//								this._initTitleCheckBox(mgCol, cm.name);
//							}
							if(cm.selectAll == true && tst.isBand != true) {
                                if(cm.editType == "checkBox" || cm.editType == "onoff") {
		                            this._initTitleCheckBox(mgCol, cm.name, cm);
                                } else if(this.getOption().treeGrid === true 
                                	&& (this.getOption().treeKey == null && j === 0 
                        				|| this.getOption().treeKey == cm.name)){
                                    this._initTitleCheckBox(mgCol, "", cm);
                                }
                            }
							mgCol.dom.sortDiv = this.createElement("div");
					        this.setStyle(mgCol.dom.sortDiv, "sortDiv");
					        //添加列排序状态
					        if(tst.isBand != true) {
						        var sortTable = this.createElement("table");
						        this.setStyle(sortTable, "sortTable");
						        sortIcon = sortTable.insertRow(0).insertCell(0);
						        this.setStyle(sortIcon, ["sortDefault"]);
						        sortTable.state = "none";
						        sortTable.onmousedown = function() {
						        	_this.sortClick = true;
						        }
						        sortTable.sortIcon = sortIcon;
						        mgCol.dom.sortDiv.appendChild(sortTable);
						        sortTable.style.display="none";
						        //设置排序事件
						        sortTable.onmouseup = function(ev) {
						        	var ev = ev || event;
						        	if(_this.getMouseButton(ev) === _this.mouseType.mtLeft) {
							        	//排序状态
							        	this.sortState = this.state;
							        	this.sortIndex = this.colIndex;
							        	if(this.colIndex != _this.colIndex) {
							        		_this.colIndex = this.colIndex;
							        	}
							        	_this.doSortAndFilter(this.sortIndex, this.sortState);							        	
						        	}
						        }
						        this.sortTables[cm.name] = sortTable;						        
					        }
					        if(this.getBrowser("safari")) {
					        	//不知道什么情况下需要往上移，
					        	//mgCol.dom.sortDiv.style.top = "-16px";
					        }
					        //解决ie浏览器下错位的问题
					        if(mgCol.childNodes[0] != null) {
					            mgCol.insertBefore(mgCol.dom.sortDiv, mgCol.childNodes[0]);
					        } else {
					        	mgCol.appendChild(mgCol.dom.sortDiv);
					        }
					        $(mgCol).attr("dataField", cm.name);
					        $(mgCol).attr("inputer", cm.inputerStr);
					        
						}
						//设置多行关系
						if(tst.rowspan > 1) {
							mgCol.setAttribute("rowSpan", tst.rowspan);
							    //重新设置高度
						    mgCol.style.height = (this.rowHeight * tst.rowspan + this._addDeff(tst.rowspan - 1)) + "px";						
							this.header[i - 1][k].rowTo += tst.rowspan - 1;
						} else {
							mgCol.style.height = this.rowHeight + "px";
						}
						mgCol.option.isBand = tst.isBand || false;
						this.titleCol[mgCol.option.cIndex] = mgCol;
						if(isFrozen) {
							//添加固定列事件
							fzCol = fzRow.insertCell(k);
							//指向自定义属性
							fzCol.option = {};
							//指向自定义dom元素
							fzCol.dom = {};
							this._initTitleEvent(fzCol);
							fzCol.mainCell = mgCol;
							//设置相关信息
							this.setStyle(fzCol, "treeListTitle");
							this._setHtml(fzCol, tst.caption, false);
							fzCol.setAttribute("colSpan", mgCol.getAttribute("colSpan"));
							fzCol.setAttribute("rowSpan", mgCol.getAttribute("rowSpan"));
							fzCol.style.height = mgCol.style.height;
							fzCol.option.bandColIndex = mgCol.option.bandColIndex;
						    fzCol.option.bandRowIndex = mgCol.option.bandRowIndex;
						    fzCol.option.fieldNames = mgCol.option.fieldNames;
						    fzCol.option.cIndex = mgCol.option.cIndex;
						    //fzCol.sort = mgCol.sort; 不知道哪里用了，
						    this.titleCol[fzCol.option.cIndex] = fzCol;
						    fzCol.option.isBand = mgCol.option.isBand;
						    if(mgCol.getAttribute("title") != null) {
						        fzCol.setAttribute("title", mgCol.getAttribute("title"));
						    }						    
//						    if(cm.editType == "checkBox" && cm.selectAll == true && tst.isBand != true) {
//								this._initTitleCheckBox(fzCol, cm.name);
//							}
						    if(cm.selectAll == true && tst.isBand != true) {
                                if(cm.editType == "checkBox" || cm.editType == "onoff") {
		                            this._initTitleCheckBox(fzCol, cm.name, cm);
                                } else if(this.getOption().treeGrid === true 
                                		&& (this.getOption().treeKey == null && j === 0 
                                				|| this.getOption().treeKey == cm.name)){
                                    this._initTitleCheckBox(fzCol, "", cm);
                                }
                            }
						    if(this.isNotEmpty(mgCol.dom.sortDiv)) {
						    	//解决ie浏览器下错位的问题
						        if(fzCol.childNodes[0] != null) {
						        	fzCol.insertBefore(mgCol.dom.sortDiv, fzCol.childNodes[0]);
						        } else {
						        	fzCol.appendChild(mgCol.dom.sortDiv);
						        }
						    	//fzCol.appendChild(mgCol.dom.sortDiv);
						    	fzCol.dom.sortDiv = mgCol.dom.sortDiv;
						    }
						    if(this.isNotEmpty(cm.inputerStr)) {
						    	$(fzCol).attr("inputer", cm.inputerStr);
						    }
						}
						k++;
					}
					tst = null;
				}
			}		
			
			//添加序号
			this.indexColWidth = 60;
			mgCol = tabMainGrid.rows[0].insertCell(0);
			mgCol.option = {};
			mgCol.style.height = "1px";
			this._setNumberValue(mgCol, "width", this.indexColWidth);
			mgCol = tabMainGrid.rows[1].insertCell(0);
			mgCol.setAttribute("rowSpan", rlen);
			this._setHtml(mgCol, this.numberCaption);
			this._setNumberValue(mgCol, "width", this.indexColWidth);
			this.setStyle(mgCol, "treeListTitle");
			//设置表格连线
			this.gridWidth += this.indexColWidth;	
			this._setNumberValue(tabMainGrid, "width", this.gridWidth);
			var xhHeight = this.rowHeight * rlen + this._addDeff(rlen - 1);
			//frozen
			//设置冻结序号列
			mgCol = this.fzGridTable.rows[0].insertCell(0);
			mgCol.option = {};
			mgCol.style.height = "1px";
			mgCol.style.width = this.indexColWidth + "px";
			mgCol = this.fzGridTable.rows[1].insertCell(0);
			mgCol.option = {};
			mgCol.setAttribute("rowSpan", rlen)
			this._setHtml(mgCol, this.numberCaption);
			mgCol.style.width = (this.indexColWidth) + "px";
			mgCol.option.cIndex = -1;
			if(this.getOption().rownumbers != false) {
				this.colNames.splice(0,0,this.numberCaption);
			}
			mgCol.onmouseup = function(ev) {
				var ev = ev || window.event;
				_this.doTitleMouseUp(this, ev);				
			}
			//全选择事件
			mgCol.onmousedown = function(ev) {
				var ev = ev || window.event;
				_this.doTitleMouseDown(this, ev);
			}
			this.titleHeight = xhHeight;
			this.hiddenFieldNames = "";
			//设置样式及边框
			mgCol.style.height = xhHeight + "px";
			this.setStyle(mgCol, "treeListTitle");
			this.fzGridTable.border = 0;
			this.fzGridTable.cellPadding = 0;
			this.fzGridTable.cellSpacing = 0;
			this.mulCellWidth = 0;
			this._hasCheckCol = false;
			this._colOrder = {"@INDEX":0};
			//非树表复选框
			if(this.treeGrid == false && this.multiSelect == true) {
				var mulIndex = 0;
				if(this.getOption().multiFirst !== false) {
					this._colOrder = {"@MUL":0,"@INDEX":1};
				} else {
					this._colOrder = {"@INDEX":0,"@MUL":1};
					mulIndex = 1;
				}
				this.mulCellWidth = 30;
				this.gridWidth += this.mulCellWidth;
				mgCol = tabMainGrid.rows[0].insertCell(mulIndex);
				mgCol.option = {};
				mgCol.style.height = "1px";
				this._setNumberValue(mgCol, "width", this.mulCellWidth);
				mgCol = tabMainGrid.rows[1].insertCell(mulIndex);
				mgCol.option = {};
				mgCol.setAttribute("rowSpan", rlen)
				this._setNumberValue(mgCol, "width", this.mulCellWidth);
				this.setStyle(mgCol, "treeListTitle");
				
				//设置冻结序号列
				mgCol = this.fzGridTable.rows[0].insertCell(mulIndex);
				mgCol.option = {};
				mgCol.style.height = "1px";
				mgCol.style.width = this.mulCellWidth + "px";
				mgCol = this.fzGridTable.rows[1].insertCell(mulIndex);
				mgCol.option = {};
				mgCol.setAttribute("rowSpan", rlen)
				//var cb = this.createElement("input");
				this._initTitleCheckBox(mgCol);
				this.mulCheckCol = mgCol;
				mgCol.style.width = (this.mulCellWidth) + "px";
				mgCol.style.textAlign = "center";
				mgCol.option.cIndex = -1;
				this.setStyle(mgCol, "treeListTitle");
				this.colCount ++;
				
				this._hasCheckCol = true;
			}
		    //当前列序号
		    this.colIndex += this._colIndexDeff();
		    //选择起始列对象。
		    this.selRect.beginColIndex = this.colIndex;
		    //结束列对象
		    this.selRect.endColIndex = this.colIndex;
			this._setNumberValue(tabMainGrid, "width", this.gridWidth);
			tabMainGrid.setAttribute("ecpClass","ecp.ui.datafield.Grid");
			tabMainGrid.border = 0;
			tabMainGrid.cellPadding = 0;
			tabMainGrid.cellSpacing = 0;
			//多表头时，插入空行
			for(var i = this.fzGridTable.rows.length; i < rlen + 1; i++) {
				this.fzGridTable.insertRow(i);
			}
			
			//在最后插入一列很小的列。以保证高度对齐.
			for(var i = 0, ilen = this.fzGridTable.rows.length; i < ilen; i++) {
				var row = this.fzGridTable.rows[i];
				var clen = row.cells.length;
				var fzCol = row.insertCell(clen);
				this._style(fzCol, "width", "1px");
				if(i == 0) {
					this._style(fzCol, "height", "1px");
				} else {
				    this._style(fzCol, "height", this.rowHeight + "px");
				}
				fzCol.noUse = true;
			}
			var upd = this._update;
			this._update = false;
			this._refreshFzTitleWidth();
			this._suitTitleHeight();	
			this._update = upd;
			mgRow = null;
			mgCol = null;
			titleSheets = null;	
			tabMainGrid = null;
	    },
	    /**
	     * 创建复选列.
	     * @name _initMulCellCol
	     * @ignore
	     */
	    _initMulCellCol:function(mgCol, width) {
	    	//+-节点宽高
        	var treePointWidth = "15px";
			var treePointHeight = "13px";
			//复选框默认宽
			var checkBoxWidth = "2px";
			//文本缩进
	    	var textPadding = "4px";
	    	mgCol.levelDiv = this.createElement("div");
			this.setStyle(mgCol.levelDiv, "component_ui_cell");
			mgCol.levelDiv.style.width = (width - 2) + "px";
			var ci = 0;
			var nodeTable = this.createElement("table");
			this.setStyle(nodeTable, "component_ui_treecol_table");
    		nodeTable.style.height = (this.rowHeight - 3) + "px";
    		var nodeR = nodeTable.insertRow(0);
    		//缩进
    		mgCol.levelTd = nodeR.insertCell(ci++);
    		mgCol.levelTd.id = "level";
    		//+-号
    		var nodeT = nodeR.insertCell(ci++);
    		mgCol.treePoint = this.createElement("div");
    		nodeT.appendChild(mgCol.treePoint);
    		nodeT.style.width = treePointWidth;
    		mgCol.treePoint.style.width = treePointWidth;
    		mgCol.treePoint.style.height = treePointHeight;
    		mgCol.treeTd = nodeT;
    		mgCol.treeTd.id = "treePoint";
    		//复选框				    		
    		nodeT = nodeR.insertCell(ci++);
    		mgCol.checkBox = new qzz.ui.input.checkbox();//this.createElement("input");
    		//mgCol.checkBox.type = "checkbox";
    		//mgCol.checkBox.style.display = "none"
    		//this.setStyle(mgCol.checkBox, "checkBox");
    		mgCol.checkBox.hide();
    		nodeT.style.width = checkBoxWidth;
    		nodeT.appendChild(mgCol.checkBox.getContainer());
    		mgCol.checkTd = nodeT;
    		mgCol.checkTd.id = "check"
    		//文本区
    		nodeT = nodeR.insertCell(ci++);
    		nodeT.style.paddingLeft = textPadding;
    		nodeT.appendChild(mgCol.rect);
    		mgCol.rectTd = nodeT;
    		mgCol.rectTd.id = "text";
    		mgCol.levelDiv.appendChild(nodeTable);
    		mgCol.appendChild(mgCol.levelDiv);
    		nodeT = null;
    		nodeR = null;
    		nodeTable = null;
	    },
	    /**
	     * 创建普通列.
	     * @name _initMulCellCol
	     * @ignore
	     */
	    _initCommonCellCol:function(editType, mgCol, colIndex, width) {
	    	if(editType == "checkBox" || editType == "onoff"
    			|| colIndex == this._colOrder["@MUL"]) {
    			mgCol.checkBox = new qzz.ui.input.checkbox();//this.createElement("input");
    			//mgCol.checkBox.type = "checkbox";
    			//mgCol.checkBox.style.display = "none"
    			//this.setStyle(mgCol.checkBox, "checkBox");
    			mgCol.checkBox.hide();
    			mgCol.rect.text.appendChild(mgCol.checkBox.getContainer());
    			mgCol.rect.style.width = "22px";
    			mgCol.rect.text.style.width = "22px";
    			if(editType == "onoff") {
    				mgCol.checkBox.onoff = new qzz.ui.button({"move":true, "width":40,"height":22,"common":["onoff_off", "onoff_on"]});
        			mgCol.checkBox.onoff.setParent(mgCol.rect.text);
        			mgCol.checkBox.onoff.hide();
    			}
    		} else if(editType == "radio") {
    			mgCol.radio = new qzz.ui.input.checkbox({"type":"radio"}); //this.createElement("input");
    			//mgCol.radio.type = "radio";
    			mgCol.radio.hide();//style.display = "none"
    			//this.setStyle(mgCol.radio, "checkBox");
    			mgCol.rect.text.appendChild(mgCol.radio.getContainer());
    		}
	    	if(width != null) {
	    	    mgCol.rect.style.width = (width - 8) + "px";
	    	    mgCol.rect.text.style.width = (width - 8) + "px";
	    	}
	    },
	    /**
	     * 创建rectDiv对象.
	     * @param {number} width
	     * @param {number} height
	     * @ignore
	     */
	    _createRectDiv:function(width, height) {
		    var rect = this.createElement("div");
        	this.setStyle(rect, "component_ui_cell");
        	if(width != null) {
	    	    rect.style.width = (width - 8) + "px";
	    	}
        	if(height != null) {
        		rect.style.height = (height - 6) + "px";
        	}
        	var ri = this.createElement("div");
        	this.setStyle(ri, "component_ui_in_cell");
        	ri.style.width = rect.style.width;
        	ri.style.height = rect.style.height;
        	rect.appendChild(ri);
        	rect.text = ri;
        	return rect;
	    },
	    /**
	     * 初始化表格体.
	     */
	    initGrid:function() {
	    	var tabMainGrid = this.gridTable;
	    	//绘制行
	        var titleCount = this.titleRowCount;
	        var scrollHeight = 0;
	        if(!this.getHScrollHide()) {
	        	scrollHeight = 16;
	        }
	        //表头已占用的高度
	        this.titleHeight = this.gridTable.rows[1].cells[0].offsetHeight;
	        if(this.titleHeight <= 0) {
	        	this.titleHeight = this._getNumberValue(this.gridTable.rows[1].cells[1].style.height, 0);
	        }
	        if(this.titleIsHide) {
	        	this.titleHeight = 0;
	        } else if(this.titleHeight === 0) {
	        	this.titleHeight = this.rowHeight * titleCount; 
	        }
	        //表体的高度=总高度-表头高度-滚动条高度-分页面板高度
	        this.bodyHeight = this._getRectHeight() - this.titleHeight - scrollHeight - this._pageBoxHeight;
	        //计算可显示的行数
	        var rcount = parseInt(this.bodyHeight/this.rowHeight, 10);
	        //判断是否有余
	        var srh = this.bodyHeight%this.rowHeight;
	        this.hafRow = false;
	        //有则再加显示一行
	        if(srh > 0 && this.getOption().footerrow != true && this.getOption().total !== true) {
	        	this.hafRow = true;
	        	rcount ++;
	        } else if(this.getOption().footerrow == true || this.getOption().total === true) {
	        	this.hafRow = true;
	        }
	        //如果显示有合计行，则自减1
	        
	        //表格高度=表头+
	        this.gridHeight = rcount * this.rowHeight + this.titleHeight;
	        //显示的行数
	        this.rowCount = rcount;
//	        if(this.getOption().footerrow || this.getOption().total === true) {
//	        	this.rowCount--;
//	        }
	        if(this.rowCount === this._rowCount) {
	        	return false;
	        }
	        this._rowCount = this.rowCount;
	        this.sheets = [];
	        this.fzSheets = [];
	        var i = titleCount;
	        //this.logBegin("ig2--------477--");
	        //循环生成所有单元格元素
	        for(; i < rcount + titleCount; i++) {
	        	var mgRow, fzRow;
	        	if(tabMainGrid.rows.length > i) {
	        		mgRow = tabMainGrid.rows[i];
	        		fzRow = this.fzGridTable.rows[i];
	        	} else {
	        	    mgRow = tabMainGrid.insertRow(i);
	        	    fzRow = this.fzGridTable.insertRow(i);
	        	}
	        	this.sheets[i - titleCount] = [];
	        	this.sheets[i - titleCount].row = mgRow;
	        	this.fzSheets[i - titleCount] = [];
	        	this.fzSheets[i - titleCount].row = fzRow;
	        	mgRow.style.height = this.rowHeight + "px";
	        	fzRow.style.height = this.rowHeight + "px";
	        	var isFrozen = true;
	        	var j = 0
	        	//+-节点宽高
	        	var treePointWidth = "12px";
				var treePointHeight = "10px";
				//复选框默认宽
				var checkBoxWidth = "2px";
				//边距
				var textPadding = "4px";
				//this.logBegin("igf1--------" + this.colCount);
	        	for(; j < this.colCount; j ++) {
	        		var mgCol;
	        		if(mgRow.cells.length > j) {
	        			mgCol = mgRow.cells[j];
	        		} else {
	        		    mgCol = mgRow.insertCell(j);
	        		    mgCol._option = {};
	        		    this.setStyle(mgCol, "gridNoneCell");
	        		    var cm = this._getColModel(j);
	        		    mgCol.rect = this._createRectDiv(cm.width, this.rowHeight);
		        		if((this.getOption().treeKey==null && j === 1 || 
		        				this.getOption().treeKey != null && this.getOption().treeKey==cm.name) && 
		        				    this.option.treeGrid != false) {
		        			this._initMulCellCol(mgCol, cm.width);
		        		} else {
			        		mgCol.appendChild(mgCol.rect);
			        		//序号列
			        		if(j === this._colOrder["@INDEX"]) {
			        			if(this.getOption().rownumbers == false) {
				        			mgCol.rect.style.display = "none";
				        		}
			        		} else {
				        		this._initCommonCellCol(cm.editType, mgCol, j, cm.width);
			        		}
		        		}
		        		//如果不是默认行高，
		        		if(this.rowHeight !== 25) {
		        		    if((this.getOption().treeKey==null && j === 1 || 
		        		    	this.getOption().treeKey != null && this.getOption().treeKey==cm.name) &&
		        		    	    this.option.treeGrid != false) {
		        		    	mgCol.levelDiv.style.height = (this.rowHeight - 6) + "px";
		        		    }
		        		}
	        		}
	        		mgCol._cellIndex = j;
	        		this.sheets[i - titleCount][j] = mgCol;
	        		if(j == this._colOrder["@INDEX"]) {
	        			//如果是序号列
	        			var fzCol;
	        			if(fzRow.cells.length > j) {
	        			    fzCol = fzRow.cells[j];	
	        			    fzCol.noUse = false;
	        			} else {
	        			    fzCol = fzRow.insertCell(j);
	        			    fzCol._option = {};
	        			    this.setStyle(fzCol, "gridNoneCell");
		        			fzCol.rect = this._createRectDiv(60);		        			
		        			if(this.getOption().rownumbers == false) {
		        				fzCol.rect.style.display = "none";
			        		}
		        			fzCol.appendChild(fzCol.rect);
	        			}
	        			fzCol._cellIndex = mgCol._cellIndex;
		        		this.fzSheets[i - titleCount][j] = fzCol;		        		
		        		fzCol = null;
	        		} else {
	        			var cm = this._getColModel(j);
	        			isFrozen = isFrozen && (this.getBooleanValue(cm.frozen, false) 
	        					|| j === this._colOrder["@MUL"]);
	        			if(isFrozen) {
	        				var fzCol;
		        			if(fzRow.cells.length > j) {
		        			    fzCol = fzRow.cells[j];	
		        			    fzCol.noUse = false;
		        			} else {
		        			    fzCol = fzRow.insertCell(j);
		        			    fzCol._option = {};
		        			    this.setStyle(fzCol, "gridNoneCell");
		        			    fzCol.rect = this._createRectDiv(cm.width, this.rowHeight);
			        			if((this.getOption().treeKey==null&&j === 1 || 
			        				this.getOption().treeKey != null && this.getOption().treeKey === cm.name) &&
			        					this.option.treeGrid != false) {
			        				this._initMulCellCol(fzCol, cm.width);
				        		} else {				        			
				        			fzCol.appendChild(fzCol.rect);
				        			if(j === this._colOrder["@INDEX"]) {
				        				if(this.getOption().rownumbers == false) {
					        				fzCol.rect.style.display = "none";
						        		}
				        			} else {
				        				this._initCommonCellCol(cm.editType, fzCol, j, cm.width);
				        			}
				        		}
				        		//如果不是默认行高.
			        			if(this.rowHeight !== 25 || this._colOrder["@MUL"] === j) {
				        		    if((this.getOption().treeKey==null&&j === 1 || 
				        		    	this.getOption().treeKey != null && this.getOption().treeKey === cm.name) &&
				        		    		this.option.treeGrid != false) {
				        		    	fzCol.levelDiv.style.height = (this.rowHeight - 6) + "px";
				        		    }
				        		}
		        			}		        			
		        			fzCol._cellIndex = mgCol._cellIndex;
			        		this.fzSheets[i - titleCount][j] = fzCol;
			        		fzCol = null;
	        			} else {
	        				while(fzRow.cells.length > j) {
	        					fzRow.deleteCell(j);
	        				}
	        			}
	        			cm = null;
	        		}
	        		mgCol = null;
	        		
	        	}//for j
	        	//this.logEnd("igf1--------");
	        	while (mgRow.cells.length > j) {
	        		mgRow.deleteCell(j);
	        	}
				//给冻结列插入最后一列，以保证对齐
				var clen = fzRow.cells.length;
				var fzCol = fzRow.insertCell(clen);
				this._style(fzCol, "width", "1px");
				fzCol.noUse = true;
	        	mgRow = null;	        	
	        } //for i
	        //this.logEnd("ig2----------");
	        var tl = tabMainGrid.rows.length;
	        while (tl > i) {
	        	tabMainGrid.deleteRow(tl - 1);
	        	this.fzGridTable.deleteRow(tl - 1);
	        	tl = tabMainGrid.rows.length;
	        }
	        while(this.fzSumTable.rows.length > 0) {
	        	this.fzSumTable.deleteRow(0);
	        }
	        while(this.sumTable.rows.length > 0) {
	        	mgRow = this.sumTable.deleteRow(0);
	        }
	        //生成小计行
	        this.totalRowCount = 0;
	        if(this.getOption().totalRever !== true) {
		        if(this.getOption().subtotal === true) {
		        	this._addTotalRow(this.totalRowCount, this.subtotalText);
		        	this.subtotalIndex = this.totalRowCount;
		        	this.totalRowCount++;
		        	this.sumTable.style.width = this.gridTable.style.width;
		        }
	        }
	        
	        //生成合计行
	        if(this.getOption().footerrow === true || this.getOption().total === true) {
	        	this._addTotalRow(this.totalRowCount, this.summaryText);
	        	this.totalIndex = this.totalRowCount;
	        	this.totalRowCount++;
	        	this.sumTable.style.width = this.gridTable.style.width;
	        }
	        //小计合计对换
	        if(this.getOption().totalRever === true) {
		        if(this.getOption().subtotal === true) {
		        	this._addTotalRow(this.totalRowCount, this.subtotalText);
		        	this.subtotalIndex = this.totalRowCount;
		        	this.totalRowCount++;
		        	this.sumTable.style.width = this.gridTable.style.width;
		        }
	        }
	        
	        this.refreshScrollBar();
	        tabMainGrid = null;
	        if(this.getOption().shrinkToFit !== false) {
	        	this.shrinkToFit(true);
	        }
	        if(this.getOption().suitToFit === true) {
	        	this.suitToFit();
	        }	        
	        //空记录状态
	        this.emptyDiv.style.left = parseInt((this.getWidth()-100)/2, 10) + "px";
	        this.emptyDiv.style.top = parseInt((this.getHeight()-20)/2, 10) + "px";

	        return true;
	    },
	    
	    _addTotalRow:function(ks, totalText) {
        	var fzRow = this.fzSumTable.insertRow(ks);
	        fzRow.style.height = (this.rowHeight - 1) + "px";
        
	        mgRow = this.sumTable.insertRow(ks);
	        mgRow.style.height = (this.rowHeight - 1) + "px";
	        
	        isFrozen = true;
	        
	        var j = 0;
	        var fzCount = 1;
	        for(;j < this.colCount; j ++) {	
	        	var fzCol = null;
	        	var mgCol = null;
	        	
	        	if(j === this._colOrder["@INDEX"]) {
	        		mgCol = mgRow.insertCell(j);
	        		mgCol._option = {};
	        		mgCol.rect = this._createRectDiv(60);
	        		mgCol.appendChild(mgCol.rect);
	        		mgCol._cellIndex = j;
	        		this._setHtml(mgCol.rect.text, "<strong>" + totalText + "</strong>", false);
	        		this.setStyle(mgCol, ["treeListIndex"]);

	        		fzCol = fzRow.insertCell(j);
	        		fzCol._option = {};
	        		fzCol.rect = this._createRectDiv(60);
	        		fzCol.appendChild(fzCol.rect);		
	        		fzCol._cellIndex = mgCol._cellIndex;
		        	this._setHtml(fzCol.rect.text, mgCol.rect.text.innerHTML, false);			        	
		        	this.setStyle(fzCol, ["treeListIndex"]);
	        	} else {
	        		var cm = this._getColModel(j);
	        		
	        		mgCol = mgRow.insertCell(j);
	        		mgCol._option = {};
	        		mgCol.rect = this._createRectDiv(cm.width, this.rowHeight);
	        		mgCol.appendChild(mgCol.rect);
	        		mgCol._cellIndex = j;
	        		this.setStyle(mgCol, ["gridReadonly","fontBold"]);
	        		
        			isFrozen = isFrozen && (this.getBooleanValue(cm.frozen, false) 
        					|| j === this._colOrder["@MUL"]);	        			
        			if(isFrozen) {
			        	fzCol = fzRow.insertCell(j);
			        	fzCol._option = {};
			        	fzCol.rect = this._createRectDiv(cm.width, this.rowHeight)
		        		fzCol.appendChild(fzCol.rect);
			        	fzCol._cellIndex = mgCol._cellIndex;
			        	
			        	if(j === this._colOrder["@MUL"]) {
			        		this.setStyle(fzCol, ["treeListIndex"]);
			        	} else {
			         	    this.setStyle(fzCol, ["gridReadonly","fontBold"]);
			        	}				        	
			        	fzCount ++;
        			}
        			
	        	}
	        	if(ks == 0) {
	        		this.addStyle(mgCol, "borderTopLine");
	        		if(fzCol != null && fzCol.noUse !== true) {
	        			this.addStyle(fzCol, "borderTopLine");
	        		}
	        	}
	        	var topCol = this._getTopCell(j); //this.gridTable.rows[0].cells[j];
	        	mgCol.style.width = topCol.style.width;
	        	mgCol.style.display = topCol.style.display;
	        	if(fzCol != null && fzCol.noUse !== true) {		        		
	        		fzCol.style.width = topCol.style.width;
	        		fzCol.style.display = topCol.style.display;
	        	}		        	
	        } //for
	    },
	    /**
	     * 获取顶行的单元格.
	     * @params index 序号
	     */
	    _getTopCell:function(index){
	    	return this.gridTable.rows[0].cells[index];
	    },
	    /**
	     * 添加过滤行.
	     */
	    _addFilterRow:function(menuTab, index, caption, height, events) {
	    	var mrow = menuTab.insertRow(index);
	        //实际菜单项目.
	    	var _this = this;
	        mrow.onmouseover = function() {
	         	_this.setStyle(this, "popMouseOver");
	        };
	        mrow.onmouseout = function() {
	          	_this.setStyle(this, "popCaption");
	        };
	        this.setStyle(mrow, "popCaption");
	        var mcell = mrow.insertCell(0);
	        this._setHtml(mcell, caption);
	        mcell.onclick = events;
	        mcell.style.height = height + "px";
	    },
	    /**
	     * 手工刷新排序状态.
	     * @param fieldName 字段
	     * @param sortState 排序状态值 up, down, none
	     */
	    setSortState:function(fieldName, sortState) {
	    	this.sortTables[fieldName].sortState = sortState;
	    	this._sortFieldName = fieldName;
	    	this.refreshSortState();
	    },
	    /**
	     * 执行排序.
	     * @param {string} fieldName 字段
	     * @param {string} sortState 排序类型 up down none
	     * @param {boolean} doRefresh 对表格进行刷新
	     * @param {function} callBack 回调函数
	     */
	    setSort:function(fieldName, sortState, doRefresh, callBack) {	
	    	if(typeof doRefresh === "function") {	    		
	    		callBack = doRefresh;
	    		doRefresh = false;
	    	}
	    	var _this = this;
        	var sortTable = _this.sortTables[fieldName];
        	if(sortTable == null || sortTable.sortState == sortState) {
        		if(typeof callBack === "function") {
	    			callBack.apply(_this, arguments)
	    		}
        	} else {
	        	sortTable.sortState = sortState;
	        	if(_this.hasbind("onSort")) {
	        		_this._sortFieldName = fieldName;
	        	    _this.trigger("onSort", [fieldName, sortState]);
	        	    //添加排序后， 刷新状态，及回调函数调用.
		    		if(doRefresh != false) {
		    		    _this.first();
		    		} else {
		    			_this.dataSet.first();
		    		}
		    		if(typeof callBack === "function") {
		    			callBack.apply(_this, arguments)
		    		}
	        	} else {
			    	_this.dataSet.doSort(fieldName, sortState, function(){	
			    		//_this.setFocus();
			    		_this._sortFieldName = fieldName;
			    		if(doRefresh != false) {
			    		    _this.first();
			    		} else {
			    			_this.dataSet.first();
			    		}
			    		if(typeof callBack === "function") {
			    			callBack.apply(_this, arguments)
			    		}
			    	});		    		
			    	_this.trigger("onSortCol",[_this.colIndex - 1, _this.colIndex, _this.state]);
	        	}
        	}
        },
	    /**
	     * 初始化过滤窗口.
	     */
	    _initFilterWindow:function() {
	    	var _this = this;
	    	this.pfilter = new qzz.ui.drop.popfilter({"sort":this.getOption().sort});
		    this.pfilter.setParent(_this.getModelBody());
		    this.pfilter.bind("onSort",function(fieldName, state){
		    	_this.setFocus();
		    	_this.setSort(fieldName, state);
			});
		    this.pfilter.bind("onClearFilter", function(fieldName){
		    	_this.setFocus();
		    	_this.setSort(_this._sortFieldName, "none", false, function() {
            		_this.dataSet.clearFilterText(function(){
            			//隐藏其它列的属性
        		    	for(var key in _this.sortTables) {
        		    		var st = _this.sortTables[key];
        		    		if(st != null) {
        		    		    st.filtered = false
        		    		}
        		    		st = null;
        		    	}
        		    	//清除过滤状态
        		    	if(_this.pageObj != null && _this.pageObj.clearFilterCount != null) {
        		    	    _this.pageObj.clearFilterCount();
        		    	}
        				_this.first();        				
    	        		_this.trigger("onFiltered", [_this.dataSet]);
        			});
            	});
			});
		    this.pfilter.bind("onFilter", function(fieldName, totalCount, selItem){
		    	_this.setFocus();
	        	_this.setSort(_this._sortFieldName, "none", false, function() {
	        		if(selItem.length > 0 && selItem.length < totalCount && selItem[0].id == "all") {
	        			selItem.splice(0, 1);
	        		}
	        		_this.dataSet.addFilterText(fieldName, selItem, function() {
	        			_this.first();
//	        			if(_this.getFieldName() !== fieldName) {
//	        			    _this.refreshSortState(fieldName);
//	        			    _this.refreshSortState(_this.getFieldName());
//	        			}
	        			//清除过滤状态
	        			if(_this.pageObj != null && _this.pageObj.setFilterCount != null) {
        		    	    _this.pageObj.setFilterCount(_this.dataSet.getRecordCount());
	        			}
        	    	    _this.trigger("onFiltered", [_this.dataSet]);
	        		});
	        	});
			});
		    this.pfilter.bind("onCancel", function(){
		    	_this.setFocus();
		    });
        },
	    /**
	     * 重构表头结构.
	     * titleString 表头结构html字符串
	     */
	    refreshTitle:function(colObject, first) {
            if(this._hasDestroy == true) return;
            this._initOption();
            if(colObject != null) {
            	if(this.isNotEmpty(colObject["colNames"])) {
            		this.option.colNames = colObject["colNames"];
            	}
            	if(this.isNotEmpty(colObject["colModels"])) {
            		this.option.colModels = colObject["colModels"];
            	}
            	if(first === true) {
            		this.getOption().defColNames = this.extend([], this.getOption().colNames);
            		this.getOption().defColModels = this.extend([], this.getOption().colModels);
            	}
            }	    	
	    	this._oldGridWidth = null;
	    	this.dataSet.keyName = this.getPKeyName();
	    	this.dataSet.itemCode = this.dataSet.keyName;
	    	var tcms = this.option.colModels;
	    	var displayFunc = {};
	    	for(var i = 0, len = tcms.length; i < len; i++) {
	    		var tcm = tcms[i];
	    		if(typeof tcm.onGetDisplay == "function") {
	    			displayFunc[tcm.name] = tcm.onGetDisplay;
	    		}
	    	}
	    	tcms = null;
	    	
	    	this.hiddenFieldNames = "";
	    	//表头解析
	    	this.option.titleSheets = [];
	    	this._initColModel();
	    	this._parseTitle();
	    	this.dataSet.setViewColModels(this.option.colModels);
	    	
	    	this._createModelJson();
	    	this.multiSelect = this.getBooleanValue(this.getBooleanValue(this.getOption().multiselect, this.getOption().multiSelect), false);
	    	this.dataSet.setMultiSelect(this.multiSelect);
	    	this.dataSet.reverGJ = this.getOption().reverGJ;
	    	this.dataSet.sumAllLevel = this.getOption().sumAllLevel;
	    	this._createTitle();
	    	this._rowCount = 0;
	    	if(this.pageObj == null) {
	    	    this._initPagerBox();
	    	}
	    	this.initGrid();
	    	this.dataSet.first();
	    	this.topNode = this.dataSet.getCurNode();
	    	var cms = this.option.colModels;
	    	for(var i = 0,len = cms.length; i < len; i++) {
	    		var cm = cms[i]
	    		if(displayFunc[cm.name] != null) {
	    		    var fcm = this.dataSet.getFieldOption(cm.name);
	    		    fcm.onGetDisplay = displayFunc[cm.name];
	    		    cm.onGetDisplay = displayFunc[cm.name];
	    		    fcm = null;
	    		}
	    	}
	    	displayFunc = null;
	    	this.refresh();
	    	if(this.getOption().shrinkToFit !== false) {
	    		this.shrinkToFit();
	    	}
	    	if(this.getOption().suitToFit === true) {
	    		this.suitToFit();
	    	}
	    },
	    isShow:function() {
	    	return this.copyDiv && this.copyDiv.offsetWidth > 0;
	    },
	    /**
	     * 多选择节点移动.
	     */
	    mulMoveRecord:function(step, callBack) {	    	
	    	if(this.topNode == null) return;
	    	var _this = this;
	    	var topIndex = this.topNode.scrIndex;
	    	this.dataSet.mulMoveNode(step, function(count, nodeAry) {
	    		//顶点重新定位.	    		
	    		var tmpNode = _this.dataSet.getCurNode();
	    		_this.dataSet.beginUpdate();
	    		_this.dataSet.first();
	    		while(!_this.dataSet.isEof()) {
	    			if(_this.dataSet.getIndex() == topIndex) {
	    				_this.topNode = _this.dataSet.getCurNode();
	    				break;
	    			}
	    			_this.dataSet.next();
	    		}
	    		_this.dataSet.select(tmpNode);
	    		_this.dataSet.endUpdate(false);
	    		_this.refresh();
	    	    //流动到焦点行
	    		_this.scrollToFocus();
	    	});
	    },
	    /**
	     * 行移动.
	     * @param step 步值
	     */
	    moveRecord:function(step, node, lockCurrent) {
	    	if(typeof node == "boolean") {
	    		refresh = node;
	    		node = null;
	    	}
	    	if(node == null) {
	    		node = this.dataSet.getCurNode();
	    	}
	    	var re = this.dataSet.moveNode(step, node, lockCurrent);
	    	if(re.fromIndex != re.toIndex) {
	    		var pNode = node.pNode;
	    		var cNode = node;
	    		var tNode = pNode.getNode(re.fromIndex);
	    		//重置显示顶点位置
				if(this.topNode.recNo === tNode.recNo) {
				    this.topNode = cNode;
				} else if(this.topNode.recNo === cNode.recNo) {
					//如果移到top位置，top指向刚移过来的节点
				    this.topNode = pNode.getNode(re.fromIndex);
				} else if(this.topNode.level == cNode.level && this.topNode.index > cNode.index) {
					//如果移到top之上，top往前移一个节点
				    this.topNode = pNode.getNode(this.topNode.index - 1);
				}
				if(lockCurrent !== true) {
		    	    this.refresh();
		    	    //流动到焦点行
					this.scrollToFocus();
				}
	    	}
	    	return re;
	    },
	    /**
	     * 刷新表格合计行.
	     * @param totalIndex 合计行序号
	     * @param node 合计行节点
	     * @param totalText 合计名称
	     */
	    _refreshTotalRow:function(totalIndex, node, totalText) {
			var mgRow = this.sumTable.rows[totalIndex];
    		var fzRow = this.fzSumTable.rows[totalIndex];
    		var flen = fzRow.cells.length;
    		var hasST = this.summaryText === "";
    		for(var j = 0, clen = mgRow.cells.length; j < clen; j++) {
    			col = mgRow.cells[j];
    			var fzCol = null;
    			if(j < flen) {
    			    fzCol = fzRow.cells[j];
    			}
    			if(j === this._colOrder["@INDEX"]) {
    				if(this.getOption().rownumbers && totalText !== "") {
    				    this._setHtml(col.rect.text, "<strong>" + totalText + "</strong>", false);
    				    this._setHtml(fzCol.rect.text,col.rect.text.innerHTML, false);
    				    hasST = true;
    				} else {
    					this._setHtml(col.rect.text, "", false);
    					this._setHtml(fzCol.rect.text, "", false);
    				}
    			} else {
    				//普通列
    				var cm = this._getColModel(j);
    				if(this.isNotEmpty(cm)) {
    					if(cm.hidden != true) {
	    					if(col.style.display == "none") {
		    					col.style.display = "";
		    					if(fzCol != null && fzCol.noUse !== true) {
		    						fzCol.style.display = "";
				    			}
	    					}
	    					if(cm.ellipsis !== false && cm.editType != "onoff" 
	    						&& cm.editType != "checkBox" && cm.editType != "radio") {
	    		    			this.addStyle(col.rect.text, "ellipsis");	    			
	    		    		}
	    		    		if($(col.rect.text).css("textOverflow") == "ellipsis") {
	    		    			col.rect.text.style.lineHeight = (this.rowHeight - 4) + "px";
	    		    		}
		    				var val = this.dataSet.getValue(cm.name, node); //getSummary(cm.name);
		    				var sumRe = this.trigger("onSummaryDraw", [this.dataSet, cm.name, node]);
		    				if(sumRe == null) {
			    				if(val != null && val !== "") {
				    				this._setHtml(col.rect.text, this.dataSet.getDisplay(cm.name, val, node), false);		
				    				//默认剧中, this.getColAlign(cm.name);
				    				col.style.textAlign = "center";				    				
				    				if(fzCol != null && fzCol.noUse !== true) {
				    				   this._setHtml(fzCol.rect.text, col.innerHTML, false);
				    				   fzCol.style.textAlign = col.style.textAlign;
				    				}
				    			} else if(!hasST){
				    				this._setHtml(col.rect.text, totalText);
				    				col.style.textAlign = "center";
				    				if(fzCol != null && fzCol.noUse !== true) {
				    				   this._setHtml(fzCol.rect.text, col.innerHTML, false);
				    				   fzCol.style.textAlign = col.style.textAlign;
				    				}
				    				//this.dataSet.setSummary(cm.name, this.summaryText);
				    				var dcm = this.dataSet.getColModel(cm.name);
									var tdt = dcm.dataType;
									dcm.dataType = "string";
				    				this.dataSet.setValue(cm.name, totalText, node);
									dcm.dataType = tdt;
				    			} else {
				    				if(cm.sum == true || cm.sum === "true") {
				    				    this._setHtml(col.rect.text, this.dataSet.getDisplay(cm.name, val, node), false);
				    			    } else {
			    						this._setHtml(col.rect.text, val, false);
			    					}
				    				//默认剧中, this.getColAlign(cm.name);
				    				col.style.textAlign = "center";
				    				if(fzCol != null && fzCol.noUse !== true) {
				    				   this._setHtml(fzCol.rect.text, col.innerHTML, false);
				    				   fzCol.style.textAlign = col.style.textAlign;
				    				}
				    			}			    				
			    				hasST = true;
		    				} else {
		    					this._setHtml(col.rect.text, val, false);
			    				col.style.textAlign = sumRe.align;
			    				if(fzCol != null && fzCol.noUse !== true) {
			    				   this._setHtml(fzCol.rect.text, col.innerHTML, false);
			    				   fzCol.style.textAlign = col.style.textAlign;
			    				}
		    				}
	    				} else {
	    					col.style.display = "none";
	    					if(fzCol != null && fzCol.noUse !== true) {
	    						fzCol.style.display = "none";
			    			}
	    				}
    				}	    				
    			} //else
    		} //for j
	    },
	    _refreshSumTab:function(state) {
	    	//如果等于0则异步一次。
	    	if(this.listDiv.offsetHeight === 0) {
	    		var _me = this;
	    		this._asynRun(function() {
	    			_me._refreshSumTab(true);
	    		}, 300);
	    		return;
	    	}
	    	var footerrow = this.getOption().footerrow === true || this.getOption().total === true;
	    	var subtotal = this.getOption().subtotal === true;
	    	//计算固定列高度
	    	var fzDivHeight = this.getOption().height;
	    	if(!this.getHScrollHide()) {
	    		if(this._scrHeight == null || this._scrHeight === 0) {
	    			this._scrHeight = this.listDiv.offsetHeight - this.listDiv.clientHeight;
	    		}
	    		if(state === true && this.listDiv.offsetHeight > 0) {
					fzDivHeight = this.listDiv.clientHeight;
				} else {
	    			fzDivHeight -= this._scrHeight;
				}
	    		//fzDivHeight -= 19;
	    	}
	    	if(this.getOption().pager) {
	    		fzDivHeight -= this._pageBoxHeight + 1;
	    		if(this.getHScrollHide()) {
		    		fzDivHeight -= 1;
		    	}
	    	}
	    	this.fzGridSheetsDiv.style.height = fzDivHeight + "px";
	    	this.listDivBox.style.height = fzDivHeight + "px";
	    	if(footerrow === true || subtotal === true) {
	    		var ldheight = this._getNumberValue(this.fzGridSheetsDiv.style.height);		   
	    		var ldwidth = this._getNumberValue(this.fzGridTable.style.width) - 1;
	    		this.fzSumTable.style.width = ldwidth + "px";
	    		this.sumTable.style.bottom = "";
	    		if(subtotal) {
	    			ldheight = ldheight - this._getNumberValue(this.fzSumTable.rows[this.subtotalIndex].style.height, 0);
	    			this._refreshTotalRow(this.subtotalIndex, this.dataSet.subNode, this.subtotalText);
	    		}
	    		if(footerrow) {
	    			ldheight = ldheight - this._getNumberValue(this.fzSumTable.rows[this.totalIndex].style.height, 0);
	    			this._refreshTotalRow(this.totalIndex, this.dataSet.rootNode, this.summaryText);
	    		}
	    		//ldheight--;

	    		this.sumTable.style.top = ldheight + "px";
	    	}
	    },
	    /**
	     * 刷新单元格夸行数
	     * @param col 单元格对象,
	     * @param rowSpan 夸行数
	     */
	    _refreshRowspan:function(col, rowSpan, ellipsis) {
	    	var px = "px";
	    	var rowHeight = (this.rowHeight * rowSpan - 6) + px;
	    	//设置夸行数量
	    	col.setAttribute("rowSpan", rowSpan);
	    	//设置内部dom行高
			col.rect.style.height = rowHeight
			//设置文本显示dom的行高
			col.rect.text.style.height = rowHeight;
			//如果是树节点的时候需要设置levelDiv
			if(col.levelDiv != null) {
				col.levelDiv.style.height = rowHeight;
			}
			//处理lineHeight显示样式
			if(ellipsis !== false) {
				//设置为总行高
			    col.rect.text.style.lineHeight = rowHeight;
			} else {
				col.rect.text.style.lineHeight = (this.rowHeight - 4) + px;
			}
	    },
	    /**
	     * 合并列单元格
	     * @param i 行
	     * @param j 列
	     * @param col 单元格对象
	     * @param fzCol 冻结单元格对象
	     */
	    _refreshGroups:function(cm, i, j, col, fzCol, pcn, ccn) {
	    	var rowSpan = "rowSpan", 
	    	    defRowSpan = 1,
	    	    px = "px",
	    	    hide = "none";
	    	//判断是否配置分组属性， 是否非单选例
	    	if (this.getOption() != null && cm.groups === true && cm.editType !== "radio") {
	    		//如果第二行开始
		    	if(i > 0) {
		    		//从面板获数组取单元格
					var pcol = this.sheets[i - 1][j];
					var pfzCol = this.fzSheets[i - 1][j];
					//分组序号
					pcol.groupIndex = i;
					//如果已经有合并对象
					if(pcol.groupCol != null) {
						//把上一个对象指向合并对象
						pcol = pcol.groupCol;
					}
					//处理冻结例
					if(fzCol != null && fzCol.noUse !== true) {
						if(pfzCol.groupCol != null) {
							pfzCol = pfzCol.groupCol;
						}
					}
					//获取默认的合并行数
					var rsp = this._getNumberValue(pcol.getAttribute(rowSpan), defRowSpan);
					//是否符合合并条件
					var ismerge = (pcn != null && pcn.level == ccn.level 
									//非复选择框
									 && ((cm.editType !=="checkBox" && cm.editType !== "onoff"
										 //内容相同
									     && this.dataSet.getValue(cm.name, pcn) == this.dataSet.getValue(cm.name, ccn)
									         //不合并空值且内容不为空，或都合并空值的
									         && (cm.groupsEmpty !== true 
									        		 && this.dataSet.getValue(cm.name, ccn) !== "" || cm.groupsEmpty === true))
									   //复选框.      
									   || ((cm.editType ==="checkBox" || cm.editType === "onoff") 
											   //内容相同
											   && this.dataSet.getValue(cm.name, pcn) == this.dataSet.getValue(cm.name, ccn)))        
								   );
					//合并前事件扩展.
					if(pcn != null && pcn.level == ccn.level && this.hasbind("onBeforeGroups")) { 
					    var bg = this.trigger("onBeforeGroups", [cm, pcn, ccn, ismerge]);
					    if(bg != null) {
					    	ismerge = bg !== false;
					    }
					}  
					
					//同级、内容完全相同, 
					if(ismerge === true) {
						//计算需要合并的行数rowSpan
						rsp = col.parentNode.rowIndex - pcol.parentNode.rowIndex + 1;
						//设置rowSpan, 及高度
						this._refreshRowspan(pcol, rsp, cm.ellipsis);
						//隐藏掉当前单元格
						col.style.display = hide;
						col.groupCol = pcol;
						if(fzCol != null && fzCol.noUse !== true) {
							//重新设置夸行数rowSpan, 及行高
							this._refreshRowspan(pfzCol, rsp, cm.ellipsis);
							//隐藏当前单元格
							fzCol.style.display = hide;
							fzCol.groupCol = pfzCol;
						}
					} else {	
						//当前单元格不需要合并的
						//计算前一行的合并行数rowSpan
						var rsp = i - pcol.groupIndex + 1;
						//设置夸行数，并设置行高， 设置lineHeight
						this._refreshRowspan(pcol, rsp, cm.ellipsis);
						//当前行数设置为默认夸行数1，默认行高
						this._refreshRowspan(col, defRowSpan, cm.ellipsis);
						//显示当前行
						col.style.display = "";
						col.groupCol = null;
						if(fzCol != null && fzCol.noUse !== true) {
							//处理冻结例
							var rsp = i - pcol.groupIndex + 1;
							//设置夸行数，并设置行高， 设置lineHeight
							this._refreshRowspan(pfzCol, rsp, cm.ellipsis);
							//当前行数设置为默认夸行数1，默认行高
							this._refreshRowspan(fzCol, defRowSpan, cm.ellipsis);
							//显示当前单元格
							fzCol.style.display = "";
							fzCol.groupCol = null;
						}
					}
				} else {
					//第一行时，初始化行高，rowSpan重置为1
					var rsp = this._getNumberValue(col.getAttribute(rowSpan), defRowSpan);
		    		if(rsp > defRowSpan) {
		    			//设置夸行数，并设置行高， 设置lineHeight
						this._refreshRowspan(col, defRowSpan, cm.ellipsis);
		    		}
		    		if(col.style.display == hide) {
		    			col.style.display == "";
		    		}
		    		if(fzCol != null && fzCol.noUse !== true) {
		    			rsp = this._getNumberValue(fzCol.getAttribute(rowSpan), defRowSpan);
			    		if(rsp > defRowSpan) {
			    			//设置夸行数，并设置行高， 设置lineHeight
							this._refreshRowspan(fzCol, defRowSpan, cm.ellipsis);
			    		}
			    		if(col.style.display == hide) {
			    			fzCol.style.display == "";
			    		}
		    		}
				}
	    	} else {
	    		//普通例处理
	    		var rsp = this._getNumberValue(col.getAttribute(rowSpan), defRowSpan);
	    		if(rsp > defRowSpan) {
	    			//设置夸行数，并设置行高， 设置lineHeight
	    			this._refreshRowspan(col, defRowSpan, cm.ellipsis);
	    		}
	    		if(col.style.display == hide) {
	    			col.style.display == "";
	    		}
	    		if(fzCol != null && fzCol.noUse !== true) {
	    			rsp = this._getNumberValue(fzCol.getAttribute(rowSpan), defRowSpan);
		    		if(rsp > defRowSpan) {
		    			//设置夸行数，并设置行高， 设置lineHeight
		    			this._refreshRowspan(fzCol, defRowSpan, cm.ellipsis);
		    		}
		    		if(col.style.display == hide) {
		    			fzCol.style.display == "";
		    		}
	    		}
	    	}
	    },
	    /**
	     * 刷新表格
	     */
	    refreash:function() {
	    	this.refresh();
	    },
		/**
		 * 隐藏单元格所有内容.
		 * @param col 单元格dom
		 */
		_emptyCell:function(col, isTree) {
			//清除内容
			for(var i = col.rect.text.childNodes.length - 1; i >= 0; i--) {
				var cd = col.rect.text.childNodes[i];
				if(cd != null) {				
					if(cd.nodeType < 3) {
						cd.style.display = "none";
					} else {
						//ie8的时候，typeof remove = "object"
						if(cd.removeNode) {						
							cd.removeNode();
						} else if(cd.remove){
						    cd.remove();
						}
					}
				}
			}
			//树表的时候会在外部有这个
			if(col.checkBox != null && col.checkBox.isShow()) {
				col.checkBox.hide();
			}
			//清除输入控件
			this._resetCell(col, isTree);
			//清除所有title
			col.setAttribute("title", "");
			//清除所有事件
			col.onclick = null;
			col.onmousedown = null;
			//清除样式
			this.setStyle(col, "gridNoneCell");			
			//清除掉树节点样式
			if(this.isNotEmpty(col.treePoint)) {
				this.clearStyle(col.treePoint)
			}
			//清除背景颜色
			col.style.backgroundColor = "";
			//清除合并行
			var rsp = this._getNumberValue(col.getAttribute("rowSpan"), 10);
    		if(rsp > 1) {
    			col.setAttribute("rowSpan", 1);
    		}
    		//删除效验图标
			if(col.valiDiv != null && col.valiDiv.parentNode == col.rect) {
				//ie8的时候，typeof remove = object
				if(col.valiDiv.remove) {
				    col.valiDiv.remove();
				} else if(col.valiDiv.removeNode) {
					col.valiDiv.removeNode();
				}
			}
		},
	    /**
	     * 刷新表格
	     */
	    refresh:function(noCach, single) {
	    	if(!this._update) return false;   	
	    	//title hide 处理表头隐藏,
		    this.refreshHiddenState();
	    	//刷新数据
	    	if(this.dataSet.curNode == null || this.dataSet.curNode.recNo == null) {
	    		this.dataSet.first();
	    	}
	    	this.mulCellSelect = false;
	    	var tmpNode = this.dataSet.getCurNode();
	    	//获取行数.
	    	var showCount = this.sheets.length;	    	
	    	this.inputFocus = false;
	    	this.selRowInShow = false;
	    	var rlen = showCount;
	    	
	    	var i = 0;
	    	this.curCell = null;
	    	var footerrow = this.getOption().footerrow === true;
	    	var footerlen = 0;
    		if(footerrow) {
    			footerlen = 0;
    		}
    		var hscrollhide = this.getHScrollHide();
    		this.dataSet.beginUpdate();
    		//刷新表格
	    	if(this.dataSet.getRecordCount() > 0) {
	    		if(this.topNode == null || this.topNode.level < 0 || this.topNode.level == null) {
	    			this.topNode = this.dataSet.getTopNode();
	    		}
	    		if(this.selRect.beginRowNode == null) {
	    			this.selRect.beginRowNode = this.dataSet.getCurNode();
	    			this.selRect.endRowNode = this.selRect.beginRowNode;
	    		}
	    		this.mulCellSelect = (this.selRect.beginColIndex < this.selRect.endColIndex 
	    				|| this.selRect.beginRowNode != null 
	    				    && this.selRect.beginRowNode.getIndex() < this.selRect.endRowNode.getIndex())
	    		
	    		this.dataSet.select(this.topNode);
	    		var gridReadOnly = this.getReadOnly();
	    		var gridRect = this._comRect||{};
	    		
	    		var gw = this.getOption().width;
	    		if(gridRect.left == null) {
	    			gridRect = {"left":0,"right":gw};
	    		}
	    		//}
	    		var colWSum = {};
	    		var colCW = {};
	    		var cs = 0;
                if(this.gridTable == null || this.gridTable.rows.length == 0) return;
	    		for(var j = 0,slen = this.gridTable.rows[0].cells.length; j < slen; j++) {
	    			var col = this.gridTable.rows[0].cells[j];
	    			var crw = 0;
	    			if(col.style.display != "none") {
		    			crw = this._getNumberValue(col.style.width);
	    			}
	    			colWSum[j] = cs;
	    			colCW[j] = crw;
	    			cs += crw;
	    		}
	    		var scrollLeft = this.listDiv.scrollLeft;
	    		//刷新所有行列
	    		//起始列
	    		var bci = 0;
	    		//结束列
	    		var eci = 10000;
	    		//冻结列
	    		var fzi = 0;
	    		//是否有合并例.
	    		var hasGroups = false;
	    		//初始化结束列
	    		if(rlen - footerlen > 0) {
	    			eci = this.sheets[0].length;
	    		}
	    		var rcc = 0;
	    		var fzLen = 0;
				if(this.fzSheets.length > 0) {
				    fzLen = this.fzSheets[0].length - 1;
				}
	    		this._lastNode = null;
	    		this._showCount = rlen - footerlen;
	    		var pcn = null;
		    	for(i = 0; i < rlen - footerlen && !this.dataSet.isEof(); i++) {
		    		var colSheets = this.sheets[i];
		    		var row = colSheets.row;
		    		var fzColSheets = this.fzSheets[i];
		    		var fzRow = fzColSheets.row;
		    		var ccn = this.dataSet.getCurNode();
		    		row._node = ccn;
		    		fzRow._node = ccn;
		    		for(var j = 0; j < eci || j <= fzi; j++) {
		    			if(j > fzi && j < bci && hasGroups === false) {
		    				//中间跳过
		    				j = bci - 1;
		    				continue;
		    			}
		    			var col = colSheets[j];
		    			var fzCol = fzColSheets[j];
		    			var prefzCol = null;
		    			if(j !== this._colOrder["@INDEX"]) {
		    				prefzCol = fzColSheets[j - 1];
		    			}
		    			if(i == 0 && col.style.display != "none") {
		    				//计算冻结列
		    				if(this.isNotEmpty(fzCol)) {
			    				fzi = j;
			    			}
		    				var colLeft = gridRect.left + colWSum[col.cellIndex] + 1 - scrollLeft;
		    				var colWidth = colCW[col.cellIndex];
			    			var al = colLeft - gridRect.left;
			    			if(al + colWidth < 0 - this.scrollWidth) {
			    				//起始列
			    				bci = j;
			    				//continue;
			    			} else if(al > gw + this.scrollWidth) {
			    				//结束列
			    				eci = j;
			    				break;
			    			}
		    			}
		    			rcc ++;
		    			var drf = true;
		    			var cm = this._getColModel(j);
		    			if(single === true) {
		    				drf = false;
		    				if(j == this._colOrder["@INDEX"] || j == this._colOrder["@MUL"] 
		    				   || (j >= this._selRect.beginColIndex && j <= this._selRect.endColIndex || fzLen === j)
		    					 && ccn.getIndex() >= this._selRect.beginRowNode.getIndex()
		    					   && ccn.getIndex() <= this._selRect.endRowNode.getIndex()
		    						|| (j >= this.selRect.beginColIndex && j <= this.selRect.endColIndex || fzLen === j)
		    						    && ccn.getIndex() >= this.selRect.beginRowNode.getIndex()
			    					       && ccn.getIndex() <= this.selRect.endRowNode.getIndex()		
		    				) {
		    					drf = true;
		    				}		    				
		    				var op = this.dataSet.getCellOption(cm.name, ccn);
		    				if(drf != true) {			    				
			    				if(op.changed != null && op.changed === true) {
			    					drf = true;
			    					op.changed = false;
			    				}			    				
		    				}		    				
		    				//有运算表达式的，需要刷新.
		    				if(drf != true && cm.validate != null && cm.validate !== "") {
		    					var fop = this.dataSet.getFieldOption(cm.name);
		    					if(fop._valiExp != null) {
		    						drf = true;
		    						op.hasValidate=false;
		    					}
		    				}
		    				
		    				op = null;
		    				//只读的时候，整行都要刷新
		    				if(drf != true && this.getReadOnly()) {
		    					if(this._curNode != null && this._curNode.recNo == ccn.recNo || tmpNode.recNo == ccn.recNo) {
		    						drf = true;
		    					}
		    				}
		    			}	
		    			//合并单元格	
		    			if(cm.hidden !== true) {
		    				if(cm.groups == true) {
		    					hasGroups = true;	
		    				}	    				
		    			    this._refreshGroups(cm, i, j, col, fzCol, pcn, ccn);
		    			}
		    			//单元格刷新函数
		    			if(drf) {
		    		        this.refreshCell(row, fzRow, col, fzCol, prefzCol, i, j, ccn, tmpNode, gridReadOnly, noCach);
		    			}		    			
		    			
		    			cm = null;
		    		    col = null;
		    		    fzCol = null;
		    		} //for j
		    		//结束行节点
		    		if(i < rlen - footerlen - 1 || hscrollhide && this.rowHeight <= 28 && !this.hafRow) {
			    		this.bottomNode = ccn;//this.dataSet.getCurNode();
			    		if(this.bottomNode.recNo == tmpNode.recNo) {
		    		    	this.selRowInShow = true;
		    		    	if(fzRow != null && this.fzSheets[0].length > 1) {
		    		    	    this.selRow = fzRow; 
		    		    	} else {
		    		    		this.selRow = row;
		    		    	}	    		    	
		    		    }
		    		} else {
		    			this._lastNode = ccn;//this.dataSet.getCurNode();
		    		}
		    		pcn = ccn;
		    		this.dataSet.next();
		    		colSheets = null;
		    		row = null;
		    		fzColSheets = null;
		    		fzRow = null;
		    		ccn = null;
		    	} //for i
		    	if(!this.selRowInShow) {
		    		this.selRow = null;		    		    
		    	}
	    	}
	    	//this.logEnd("refresh_1_" + rcc);
	    	//处理表格排序状态
	    	this.refreshSortState();
	    	//清除空数据行
	    	var treeKey = this.getOption().treeKey || "";
	    	for(; i < rlen; i++) {
	    		var colSheets = this.sheets[i];
	    		var fzColSheets = this.fzSheets[i];
	    		for(var j = 0, clen = colSheets.length; j < clen; j++) {	 
	    			var cm = this._getColModel(j);
	    			var fieldName = cm.name;
	    			var col = colSheets[j];	    			
	    			//清除单元格相关内容
	    			var isTree = this.getOption().treeGrid == true && (treeKey === "" && j == 1 || 
	    					treeKey === fieldName);
	    			this._emptyCell(col, isTree);
	    			if(j === this._colOrder["@INDEX"]) {
	    				//处理序号列隐藏/显示
	    				if(this.getOption().rownumbers) {
	    					col.style.width = "60px";
	    					col.rect.style.display = "";
	    				} else {
	    					col.style.width = "1px";
	    					col.rect.style.display = "none";
	    				}
	    				fieldName = "@INDEX";
	    			} else {
	    				if(this.isEmpty(cm) && j == this._colOrder["@MUL"]) {
	    					fieldName = "@MUL";
	    				}
	    				//处理例隐藏显示
	    				if(cm.hidden === true) {
		    				col.style.display = "none";
		    			} else {
		    				col.style.display = "";
		    			}
	    			}
	    			col.style.backgroundColor = "";
	    			if(this.isNotEmpty(fzColSheets[j])) {
	    				var fcol = fzColSheets[j];
	    				//清除单元格相关内容
	    				this._emptyCell(fcol, isTree);
	    				if(j === this._colOrder["@INDEX"]) {
		    				if(this.getOption().rownumbers) {
		    					fcol.style.width = "60px";
		    					fcol.rect.style.display = "";
		    				} else {
		    					fcol.style.width = "1px";
		    					fcol.rect.style.display = "none";
		    				}
		    			} else {
		    				
		    			}
		    			if(fcol.style.display !== col.style.display) {
		    				fcol.style.display = col.style.display;
		    			}
		    			fcol.style.backgroundColor = "";
			    		//事件
		    			this.trigger("onCellClear_" + fieldName, [this.dataSet, fieldName, fcol]);
		    			fcol = null;		    			
	    			} else {
	    				this.trigger("onCellClear_" + fieldName, [this.dataSet, fieldName, col]);
	    			}
	    			col = null;
	    		}
	    		colSheets = null;
	    		fzColSheets = null;
	    	}
	    	//添加合计行
	    	this._refreshSumTab();	    	
	    	this.dataSet.select(tmpNode);
	    	this.dataSet.endUpdate(false);
	    	//刷新滚动条
	    	this.refreshScrollBar();
	    	//只留当前编辑框为焦点。
	    	for(var key in this.editObjects) {
	    		this.editObjects[key].focus = false;
	    	}
	    	//处理输入控件.
	    	if(this.inputFocus && this.isNotEmpty(this.editObject)) {
	    		if(this._hasScroll !== true) {
	    			if(typeof this.editObject.setFocus == "function") {
	    		        this.editObject.setFocus();
	    			}
	    		}
	    	} else {
	    		this.editObject = null;
	    	}
	    	//处理多选择状态
	    	if(this.copyInput != null && this.dataSet.getRecordCount() > 0 && this.focus) {
		    	if(this.mulCellSelect) {
	        		this.copyInput.value = this.getCopyData();
	        		var cip = this.copyInput;	        		
	        		if(this._setTimeoutStack["copyFocus"] == null) {
	        			this._setTimeoutStack["copyFocus"] = [];
	        		}
	        		this._setTimeoutStack["copyFocus"].push("1");
		        	this._asynRun(function(){
		        		if(this.cellMouseDown == false) {
			        		if(cip.offsetHeight > 0) {
			        			 cip.select(); 
			        			 cip.focus();
			        		}
		        		}
			        	cip = null
		        	}, 10);
	        	} else {
	        		this.copyInput.value = "";
	        		if(this.getCellReadOnly(this.getFieldName())) {
	        			this.copyInput.value = this.getCopyData();
		        		var cip = this.copyInput;
		        		this._asynRun(function(){
		        			if(this.cellMouseDown == false) {
			        			if(cip.offsetHeight > 0) {
			        			    cip.select(); 
			        			    cip.focus();
			        			}
		        			}
			        		cip = null;
		        		}, 10); 
	        		}
	        	}
	    	}
	    	this._asynRun(function(){
	    		if(this != null && this.listDiv != null && this.listDiv.offsetWidth != 0) {
	    		    this.listDiv.scrollTop = 0;
	    		}
	    		if(this != null && this.fzGridSheetsDiv != null && this.fzGridSheetsDiv.offsetWidth != 0) {
	    			this.fzGridSheetsDiv.scrollTop = 0;
	    		}
	    	}, 50);	    	
	    	this.hasCopy = false;
	    	this.priorColIndex = this.colIndex;
	    	if(this.thisWindow.style.width == "") {
	    		this.thisWindow.style.width = this.getOption().width + "px";
	    	}
	    	this._addNew = false;
	    	//缓存当前选择区域
	    	this._selRect = $.extend({}, this.selRect);
	    	this._curNode = this.dataSet.getCurNode();
	    	
	    	//隐藏显示是否有数据状态
    		if(this.dataSet.getRecordCount() > 0) {
    			this.emptyDiv.style.display = "none";	
    		} else {
    			this.emptyDiv.style.display = "";
    		}    		
	    	//this.logEnd("refresh");
	    },
	    /**
	     * 双击事件.
	     */
	    _ondbclick:function() {
	    	var _this = this._option._this;	    	
	    	if(typeof _this.onDBClick === "function") {
    			try {
    				if(this.editObject != null && this.editObject.isFocus()) {
    		    		this.editObject.doBlur(true);
    		    	}
    			    _this.onDBClick(_this);
    			} catch(e) {
    				_this.logInfo("[onDBClick] error:" + e.message + e.stack);
    			}
    		}
	    	if(_this.hasbind("onDBClick")) {
	    		
	    		if(_this.editObject != null && typeof _this.editObject.isFocus == "function" 
	    			&& _this.editObject.isFocus()) {
		    		_this.editObject.doBlur(true);
		    	}
	    		_this.trigger("onDBClick", [_this]);
	    	}
	    },
	    /**
	     * 树节点按钮点击事件.
	     * @name _onTreePointClick
	     * @ignore
	     */
	    _onTreePointClick:function() {
	    	var _this = this._option._this;
	    	var cNode = this._option.node;
	    	//提交变更的数据.
	    	_this.post();
			if(cNode.expanded) {
				cNode.collapse();		    				    
			} else {
				cNode.expand();
				if(typeof _this.onExpand === "function") {
					_this.dataSet.select(cNode);
					_this.onExpand(cNode);
					cNode.hasExpand = true;
				}
				if(_this.hasbind("onExpand")) {
					_this.dataSet.select(cNode);
				    _this.trigger("onExpand", [cNode]);
				    cNode.hasExpand = true;
				}
			}
			//刷新后续数据
			_this.dataSet.select(cNode);
			_this.selRect.beginRowNode = cNode;
			_this.selRect.endRowNode = cNode;
			_this.colIndex = 1;
			_this.selRect.beginColIndex = _this.colIndex;
			_this.selRect.endColIndex = _this.colIndex;
			_this.isSelect = false;
			_this.refresh();
			_this.isSelect = true;
			_this.isTreePointClick = true;
			_this = null;
		},
		/**
		 * 复选框点击事件.
		 * @name _onTreeCheckBoxClick
		 * @ignore
		 */
		_onTreeCheckBoxClick:function(ev) {
			var opt = this._option;
			var _this = opt._this;
			_this.post();
			_this.dataSet.select(opt._cNode);
			if(!opt._cNode.checkState) {
		        _this.dataSet.setCheck(opt._cNode);
		    } else {
		    	_this.dataSet.setUnCheck(opt._cNode);
		    }
			if(opt._cNode.level == 0) {
			    _this.setTitleChecked("@MUL", opt._cNode.pNode.count == opt._cNode.pNode.childCheckCount);
			}
			//复选择选择事件.
			if(typeof _this.onCheckChanged === "function") {
				try {
					_this.onCheckChanged(opt._cNode, opt._cNode.checkState, "@MUL");		    						
				} catch(e) {
					_this.logInfo("[onCheckChanged] error:" + e.message + e.stack);
				}
			}
			_this.trigger("onCheckChanged", [opt._cNode, opt._cNode.checkState, "@MUL"]);
			_this.trigger("onSelectRow",[opt._cNode, opt._cNode.checkState, "@MUL"]);
			if(_this.isSelect && _this.focus) {
				_this.trigger("onSelectEcpRow",[_this.getSelectRowIds(),"@MUL",ev]);
			}
			//换行的时候不用刷新
			//if(this._cNode.recNo == _this.dataSet.getCurNode().recNo) {
		    _this.refresh();
			//}
			_this = null;
			opt = null;
		},
		/**
		 * 单选框点击事件.
		 * @name _onCommonRadioClick
		 * @ignore
		 */
		_onCommonRadioClick:function() {
			if(this.getCheck()) {
				var opt = this._option;
				var grid = opt._this;
				var fieldName = opt._fieldName;
				var cm = opt._colModel;
				var tmpNode = grid.radioCheck[fieldName];
				if(tmpNode != null && tmpNode.recNo === opt._cNode.recNo) {
					return;
				}
				//保存原来的值.
				var oldValue = grid.dataSet.getValue(fieldName, opt._cNode);
				//设置新值
				grid.dataSet.setValue(fieldName, cm.editoptions.check, opt._cNode);				
				if(grid.isNotEmpty(tmpNode)) {
					grid.dataSet.setValue(fieldName, cm.editoptions.uncheck, tmpNode);
				}
				//缓存当前选择
				grid.radioCheck[fieldName] = opt._cNode;
				var checkState = this.getCheck();
				//复选择选择事件.
				if(typeof grid.onCheckChanged === "function") {
					try {
						grid.onCheckChanged(opt._cNode, checkState, fieldName);						
					} catch(e) {
						grid.logInfo("[onCheckChanged] error:" + e.message + e.stack);
					}
				}
				grid.trigger("onCheckChanged", [opt._cNode, checkState, fieldName]);
				grid.trigger("onSelectRow",[opt._cNode,checkState, fieldName]);
				grid.dataPost = true;
				var ds = grid.dataSet;
				var dt = ds.getDataType(fieldName);
				var value = ds.getValue(fieldName);
				var text = ds.getDisplay(fieldName);
				var op = ds.getOption(fieldName, opt._cNode);
				//控制编辑中的事件.
	    		if(typeof grid.onEditing == "function") {
	    			try {					    				
	    				if(grid.onEditing(cm, oldValue, value, op, opt._cNode) == false) {
	    					grid.dataSet.setValue(fieldName, oldValue, opt._cNode);
	    					if(grid.isNotEmpty(tmpNode) && tmpNode._hasDestroy !== true) {
	    						grid.dataSet.setValue(fieldName, cm.editoptions.check, tmpNode);
	    						grid.radioCheck[fieldName] = tmpNode;
	    					}
	    					grid.dataPost = false;
	    					grid.focus = false;
	    				}
	    				
		    		} catch(e) {
		    			this.logInfo("[onEditing]Error:" + e.message);	    			
		    		}
	    		}
	    		if(grid.hasbind("onEditing")) {
	    			if(grid.trigger("onEditing",[cm, oldValue, value, op, opt._cNode]) == false) {
	    				grid.dataSet.setValue(fieldName, oldValue, opt._cNode);
    					if(grid.isNotEmpty(tmpNode)) {
    						grid.dataSet.setValue(fieldName, cm.editoptions.check, tmpNode);
    						grid.radioCheck[fieldName] = tmpNode;
    					}
    					grid.dataPost = false;
    					grid.focus = false;
	    			}
	    		}
				//编辑后事件.
				if(grid.dataPost && typeof grid.onAfterEdit == "function") {
					try {
						grid.onAfterEdit(dt, fieldName, value, text, cm, opt._cNode);
					} catch(e) {
						grid.logInfo("[onAfterEdit] error:" + e.message + e.stack);
					}
				}
				grid.trigger("onAfterEdit",[dt, fieldName, value, text, cm, opt._cNode]);
				grid.trigger("afterEditCell",[grid.getPKeyName(),fieldName,value]);
				ds = null;
				op = null;
				opt = null;
			}
		},
        /**
         * 更新合并内容.
         * @param fieldName 字段
         * @param oldValue 旧值
         * @param value 新值
         */
	    _updateGroupValues:function(fieldName, oldValue, value) {
	    	if(oldValue==null || oldValue==="") return;
	    	//开始刷新
	    	this.dataSet.beginUpdate();
	    	//获取当前行节点
	    	var cn = this.dataSet.getCurNode();
	    	//往后更新
	    	this.dataSet.next();
	    	//循环是否结束
	    	while(!this.dataSet.isEof()) {
	    		//如果相同层次，原来值相同，则一起更新成新值
	    		if(cn.level == this.dataSet.getLevel() && this.dataSet.getValue(fieldName) === oldValue) {
	    			this.dataSet.setValue(fieldName, value);
	    		} else {
	    			break;
	    		}
	    		this.dataSet.next();
	    	}
	    	this.dataSet.select(cn);
	    	//往前更新
	    	this.dataSet.prior();
	    	while(!this.dataSet.isEof()) {
	    		//如果相同层次，原来值相同，则一起更新成新值
	    		if(cn.level == this.dataSet.getLevel() && this.dataSet.getValue(fieldName) === oldValue) {
	    			this.dataSet.setValue(fieldName, value);
	    		} else {
	    			break;
	    		}
	    		this.dataSet.prior();
	    	}
	    	//重新定位到当前行
	    	this.dataSet.select(cn);
	    	//完成刷新
	    	this.dataSet.endUpdate(false);
	    },
		/**
		 * 复选框点击事件.
		 * @name _onCommonCheckBoxClick
		 * @ignore
		 */
		_onCommonCheckBoxClick:function() {
			var opt = this._option;
			var grid = opt._this;
			var fieldName = opt._fieldName;
			var cm = opt._colModel;
			var oldValue = grid.dataSet.getValue(fieldName, opt._cNode);
			var re;
			var checkState = this.getCheck();
			if(checkState) {
				re = cm.editoptions.check;
				//如果配置了全选择
				if(cm.selectAll == true) {
					var selAll = true;
					grid.dataSet.each(function(node) {
						if(this.getValue(fieldName) !== re) {
							selAll = false;
							return false;
						}
					}, function() {
						if(selAll) {
							grid.setTitleChecked(fieldName, true);
						}
					})
				}
			} else {
				re = cm.editoptions.uncheck;
				grid.setTitleChecked(fieldName, false);
			}
			if(typeof re == "string") {
				if(cm.dataType == "number") {
				    re = parseInt(re, 10);
				} else if(cm.dataType == "boolean") {
					re = grid.getBooleanValue(re, false);
				}
			}
			grid.dataSet.setValue(fieldName, re, opt._cNode);
			if(cm.groups === true) {
			    grid._updateGroupValues(fieldName, oldValue, re);
			}
			
			//复选择选择事件.
			if(typeof grid.onCheckChanged === "function") {
				try {
					grid.onCheckChanged(opt._cNode, checkState, fieldName);
					
				} catch(e) {
					grid.logInfo("[onCheckChanged] error:" + e.message + e.stack);
				}
			}
			grid.trigger("onCheckChanged", [opt._cNode, checkState, fieldName]);
			grid.trigger("onSelectRow",[opt._cNode, checkState, fieldName]);
			grid.dataPost = true;
			var ds = grid.dataSet;
			var dt = ds.getDataType(fieldName);
			var value = ds.getValue(fieldName);
			var text = ds.getDisplay(fieldName);
			var op = ds.getOption(fieldName, opt._cNode);
			//控制编辑中的事件.
    		if(typeof grid.onEditing == "function") {
    			try {
    				if(grid.onEditing(cm, oldValue, value, op, opt._cNode) == false) {
    					grid.dataSet.setValue(fieldName, oldValue, opt._cNode);
    					if(cm.groups === true) {
    					    grid._updateGroupValues(fieldName, re, oldValue);
    					}
    					grid.dataPost = false;
    					grid.focus = false;
    				}
	    		} catch(e) {
	    			grid.logInfo("[onEditing]Error:" + e.message);	    			
	    		}
    		}
    		if(grid.hasbind("onEditing")) {
    			if(grid.trigger("onEditing",[cm, oldValue, value, op, opt._cNode]) == false) {
    				grid.dataSet.setValue(fieldName, oldValue, opt._cNode);
    				if(cm.groups === true) {
    				    grid._updateGroupValues(fieldName, re, oldValue);
    				}
					grid.dataPost = false;
					grid.focus = false;
    			}
    		}
			//编辑后事件.
			if(grid.dataPost && typeof grid.onAfterEdit == "function") {
				try {
					grid.onAfterEdit(dt, fieldName, value, text, cm, opt._cNode);					
				} catch(e) {
					grid.logInfo("[onAfterEdit] error:" + e.message + e.stack);
				}
			}
			grid.trigger("onAfterEdit",[dt, fieldName, value, text, cm, opt._cNode]);
			grid.trigger("afterEditCell",[grid.getPKeyName(),fieldName,value]);
			ds = null;
			op = null;
			opt = null;
		},
		/**
		 * 获取数据及属性.
		 */
		_getCellOption:function(fieldName, noCach) {
			return {"option":this.dataSet.getCellOption(fieldName),
			    "value":this.dataSet.getValue(fieldName),
			    "text":this.dataSet.getDisplay(fieldName, undefined, undefined, noCach)
			}
		},
		/**
	     * 获取对齐方式.
	     * @param fieldName 字段名称
	     * @return 返回对齐方式
	     */
	    getColAlign:function(fieldName) {
	    	var align = "";
	    	
	    	var fo = this.getColModel(fieldName);
	    	if(fo == null && fieldName == "rn") return "center";
	    	var dt = "";
	    	//以配置的为主
	    	if(fo != null) {	    		
	    	    if(fo.align != null) {
	    	    	align = fo.align;
	    	    }
	    	    dt = fo.dataType;
	    	} 
	    	if(align == null || align === ""){
		    	if(dt == null || dt === "") {
		    		dt = "string";
		    	}
	    		//按数据类型自动生成对齐方式
		    	var dataType = dt;//.toLowerCase();	    	
	    		if(dataType === "number" || dataType === "int" || dataType === "float") {
	    			align = "right";
	    		} else if(dataType != "string"){
	    			align = "center";
	    		} else {
	    			align = "left";
	    		}   		
	    	}
	    	return align;
	    },
		/**
		 * 区域选择样式调整.
		 */
		_mulSelectStyle:function(col, fcol, prefzCol, cNode, selNode, rowIndex, colIndex, gridReadOnly, colReadOnly, isFocusCell, hasfrozen) {
			if(fcol == null && prefzCol != null && prefzCol.noUse !== true && prefzCol.cellIndex == 0) {
				this.delStyle(prefzCol, "borderRightFocus");
			}
			
			if(gridReadOnly) {
    			//只读状态
    			if(cNode.recNo === selNode.recNo) {
    				if(colIndex == this.colIndex) {    					
    					//合并行的时候，选择处理
    					if(this.mulCellSelect !== true && col.style.display == "none" && col.groupCol != null) {
    						col = col.groupCol;
    					}
	    				var css = "gridFocusCell";
	    				if(!this.focus && this.getOption().heightLight !== true) {
			    			css = "gridNoFocusFocusCell";
			    		}
	    				if(col.className !== css) {
		    				this.setStyle(col, css);
		    				//设置边距   				
		    				if(hasfrozen) {
		    					this.setStyle(fcol, css);	    					
		    				}
	    				}
	    				//if(!hasfrozen && prefzCol != null) {
	    				//	this.addStyle(prefzCol, "borderRightFocus");
	    				//}
	    				this.curCell = col;
	    				this.curColIndex = this.colIndex;
	    			} else {
	    				var css = "gridSelRow";
	    			    if(this.focus != true || this.selRect.beginRowNode.getIndex() != this.selRect.endRowNode.getIndex()) {
	    					if(rowIndex % 2 == 0) {
	        					css = "gridReadonly";
	        				} else {
	        					css = "gridCell";
	        				}
	    			    }
	    			    if(this.mulCellSelect !== true && col.style.display == "none" && col.groupCol != null) {
	    			    	var b = col.groupCol.parentNode.rowIndex;
	    			    	var e = col.parentNode.rowIndex;
	    			    	var c = b;
	    			    	if(this.curCell != null) {
	    			    	    c = this.curCell.parentNode.rowIndex;
	    			    	}
	    			    	if(c >= b && c <= e) {
    						    col = col.groupCol;
	    			    	}
    					}
	    				if(col.className !== css) {
		    			    this.setStyle(col, css);
	    				}
	    				if(hasfrozen && fcol.className !== css) {
                        	this.setStyle(fcol, css);
	    				}
	    			}
    			} else {
    				if(rowIndex % 2 == 0) {
    					css = "gridReadonly";
    				} else {
    					css = "gridCell";
    				}
    				if(this.mulCellSelect !== true 
    						&& col.style.display == "none" && col.groupCol != null && this.curCell != col.groupCol) {
    					var b = col.groupCol.parentNode.rowIndex;
    			    	var e = col.parentNode.rowIndex;
    			    	var c = -1;
    			    	if(this.curCell != null) {
    			    	    c = this.curCell.parentNode.rowIndex;
    			    	}
    			    	if(c < b || c > e) {
						    col = col.groupCol;
    			    	}
					}
    				if(col.className !== css) {
	    				this.setStyle(col, css);	                    
    				}
    				if(hasfrozen && fcol.className !== css) {
                        this.setStyle(fcol, css);
	    		    }
    			}	    			
    		} else {
    			//焦点行
    			if(isFocusCell) {
    				//焦点单元格
    				var css = "gridEditFocusCell";
		    		if(colReadOnly) {
		    			css = "gridFocusCell";
		    		}
		    		if(!this.focus && this.getOption().heightLight !== true) {
		    			css = "gridNoFocusFocusCell";
		    		}
		    		if(col.className !== css) {
			    		this.setStyle(col, css);
			    		if(hasfrozen) {
			    			this.setStyle(fcol, css);
			    		}		    				
		    		}
		    		//if(!hasfrozen && prefzCol != null) {
    				//	this.addStyle(prefzCol, "borderRightFocus");
    				//}
    				this.curCell = col;
    				this.curColIndex = this.colIndex;
    			} else if(this.mulCellSelect){ 
    				if(colReadOnly){
    					if(col.className !== "gridReadOnly") {
			    			this.setStyle(col, "gridReadonly");
    					}
    					if(hasfrozen && fcol.className !== "gridReadOnly") {
    						this.setStyle(fcol, "gridReadonly");
    					}
		    		} else {
		    			if(col.className !== "gridCell") {
		    				this.setStyle(col, "gridCell");
		    			}
		    			if(hasfrozen && fcol.className !== "gridCell") {
    						this.setStyle(fcol, "gridCell");
    					}
	    			}
                } else if(colReadOnly){
	    			if(col.className !== "gridReadonly") {
		    			this.setStyle(col, "gridReadonly");		    			
	    			}
	    			if(hasfrozen && fcol.className !== "gridReadonly") {
	    				this.setStyle(fcol, "gridReadonly");
    				}
	    		} else {
	    			if(col.className != "gridCell") {
		    			this.setStyle(col, "gridCell");
	    			}
	    			if(hasfrozen && fcol.className != "gridCell") {
	    				this.setStyle(fcol, "gridCell");
    				}
	    		}
    	    }
			
    		if(this.mulCellSelect
	    	    && cNode.scrIndex <= this.selRect.endRowNode.getIndex()
	    			&& cNode.scrIndex >= this.selRect.beginRowNode.getIndex()
	    				&& colIndex <= this.selRect.endColIndex
	    				    && colIndex >= this.selRect.beginColIndex) {
	    		    //区域选择样式处理
	    			if(this.focus || this.getOption().heightLight === true) {		    			
	    				if(isFocusCell) {
	    					if(col.className !== "gridCell") {
		    					this.setStyle(col, "gridCell");
			    				if(hasfrozen) {
			    					this.setStyle(fcol, "gridCell");
			    				}
	    					}
	    				} else {
	    					if(col.className != "gridSelRow") {
		    			        this.setStyle(col, "gridSelRow");
		                        if(hasfrozen) {
		                        	this.setStyle(fcol, "gridSelRow");
			    				}
	    					}
	                        if(this.hasCopy) {
	                        	this.addStyle(col, "cellCopySate");
	                        	if(hasfrozen) {
		                        	this.addStyle(fcol, "cellCopySate");
			    				}		                        	
	                        }
                        }	                        
                        if(colIndex == this.selRect.beginColIndex) {
                        	this.addStyle(col, "borderLeftFocus");
                        	if(hasfrozen) {
	                        	this.addStyle(fcol, "borderLeftFocus");
		    				} //else if(prefzCol != null) {
		    					//this.addStyle(prefzCol, "borderRightFocus");
		    				//}
                        	//if(fcol == null && prefzCol != null) {
    	                	//	this.addStyle(prefzCol, "borderRightFocus");
    	                	//}
                        }
                        if(colIndex == this.selRect.endColIndex) {
                        	this.addStyle(col, "borderRightFocus");
                        	if(hasfrozen) {
	                        	this.addStyle(fcol, "borderRightFocus");
		    				}
                        }
                        if(colIndex <= this.selRect.endColIndex
    				          && colIndex >= this.selRect.beginColIndex) {
	                        if(cNode.getIndex() == this.selRect.beginRowNode.getIndex()) {
	                        	this.addStyle(col, "borderTopFocus");
	                        	if(hasfrozen) {
		                        	this.addStyle(fcol, "borderTopFocus");
			    				}
	                        }
	                        if(cNode.getIndex() == this.selRect.endRowNode.getIndex()) {
	                        	if(col.style.display === "none" && col.groupCol != null) {
	                        		col = col.groupCol;
	                        	}
	                        	this.addStyle(col, "borderBottomFocus");	                        	
	                        	if(hasfrozen) {
	                        		if(fcol.style.display === "none" && fcol.groupCol != null) {
		                        		fcol = fcol.groupCol;
		                        	}
		                        	this.addStyle(fcol, "borderBottomFocus");
			    				}
	                        }
                        }
	                } else {
	                	if(col.className !== "gridNoFocusSelRow") {
                            this.setStyle(col, "gridNoFocusSelRow");
	                        if(hasfrozen) {
	                            this.setStyle(fcol, "gridNoFocusSelRow");
		    			    }
	                	}
	                	if(isFocusCell) {
	                		col.className = "gridNoFocusFocusCell";
	                	}
                    }
	    			isFocusCell = false;
            }
		},
		/**
		 * 还原单元格状态.
		 * @param {object} col 单元格td.
		 * @ignore
		 */
		_resetCell:function(col, isTree) {
			//行缓存一下.
			fragment = document.createDocumentFragment(); 
			fragment.appendChild(col.rect);
			if(isTree) {				
				this._setHtml(col.rectTd, "", false);
				col.rectTd.appendChild(col.rect);
			} else {
				this._setHtml(col, "", false);
				col.appendChild(col.rect);
			}
			col.rect.appendChild(col.rect.text);
            col.rect.style.display = "";
        },
		/**
		 * 刷新树型结构.
		 */
		_refreshTreeCol:function(col, fcol, hasfrozen, cNode, fieldName, text, value, isFocusCell, colReadOnly, cm) {
			//如果是第一列  virtual 虚拟加载    			
    		if(cNode.count > 0 || this.getOption().virtual && cNode.hasExpand != true && cNode.data.isLeaf != true) {
    		    if(hasfrozen) {
    		    	if(fcol.treePoint._option == null) {
        				fcol.treePoint._option = {};
        			}
        			var opt = fcol.treePoint._option;
    		    	if(opt._this == null) {
    		    		opt._this = this;
    		    	}
    		    	opt.node = cNode;
	    		    fcol.treePoint.onclick = this._onTreePointClick;
    		    } else {
    		    	//添加节点加号
        			if(col.treePoint._option == null) {
        				col.treePoint._option = {};
        			}
        			var opt = col.treePoint._option;
        			if(opt._this == null) {
        				opt._this = this;
        			}
        			opt.node = cNode;
        		    col.treePoint.onclick = this._onTreePointClick;
    		    }
	    		
				if(hasfrozen) {
					if(fcol.rect.style.display !== "") {
						this._resetCell(fcol, true);
    				}	
				} else {
					if(col.rect.style.display !== "") {
		    			this._resetCell(col, true);
    				}
				}
	    		//节点加号样式
	    		if(cNode.expanded && cNode.count > 0) {	    			
	    			if(hasfrozen) {
	    				this.setStyle(fcol.treePoint, "component_ui_listview_node_expand");
	    			} else {
	    				this.setStyle(col.treePoint, "component_ui_listview_node_expand");
	    			}		    			
	    		} else {
	    			if(cNode.count == 0) {
	    				cNode.expanded = false;
	    			}	    			
	    			if(hasfrozen) {
	    				this.setStyle(fcol.treePoint, "component_ui_listview_node_collapse");
	    			} else {
	    				this.setStyle(col.treePoint, "component_ui_listview_node_collapse");
	    			}
	    		}
    		} else {    			
	    		if(hasfrozen) {
	    			this.clearStyle(fcol.treePoint);
	    		} else {
	    			this.clearStyle(col.treePoint);
	    		}
    					    		
				if(hasfrozen) {
					if(fcol.rect.style.display !== "") {
						this._resetCell(fcol, true);
    				}	
				} else {
					if(col.rect.style.display !== "") {   
		    			this._resetCell(col, true);
    				}
				}
    		} // else
    		if(this.multiSelect) {
    			//复选择处理。
    			if(col.checkBox.isShow() !== true) {
    				col.checkBox.show();
    				col.checkBox.getContainer().parentElement.style.width = "14px";
    				if(hasfrozen) {
    					fcol.checkBox.show();
    					fcol.checkBox.getContainer().parentElement.style.width = "14px";
    				}
    			}    			
    			if(hasfrozen) {
    				if(cNode.enable) {
	    				fcol.checkBox.setDisable(false);
	    			} else {
	    				fcol.checkBox.setDisable(true);
	    			}
    				fcol.checkBox.setCheck(cNode.checkState);
    				if(fcol.checkBox._option == null) {
    					fcol.checkBox._option = {};
    				}
    				var opt = fcol.checkBox._option;
    				if(opt._this == null) {
    					opt._this = this;
    				}
    				opt._cNode = cNode;
    				fcol.checkBox.bind("onClick", this._onTreeCheckBoxClick, true);
    			} else {
    				if(cNode.enable) {
        				col.checkBox.setDisable(false);
        			} else {
        				col.checkBox.setDisable(true);
        			}
    				col.checkBox.setCheck(cNode.checkState);
    				if(col.checkBox._option == null) {
    					col.checkBox._option = {};
    				}
    				var opt = col.checkBox._option;
    				if(opt._this == null) {
    					opt._this = this;
    				}
    				opt._cNode = cNode;
        			col.checkBox.bind("onClick", this._onTreeCheckBoxClick, true);
    			}	    			
    		} else {
    			//单选择处理
    			if(col.checkBox.isShow()) { 
    				col.checkBox.hide();
    				col.checkBox.getContainer().parentElement.style.width = "2px";
    				if(hasfrozen) {
    					fcol.checkBox.hide();
    					fcol.checkBox.getContainer().parentElement.style.width = "2px";
    				}
    			}
    		}
    		if(this.treeGrid == false) {
    			if(col.levelTd.style.display != "none") {    				
	    			if(hasfrozen) {
	    				fcol.levelTd.style.display = "none";
	    				fcol.treeTd.style.display = "none";
	    				if(!this.multiSelect) {
	    				    fcol.checkTd.style.display = "none";
	    				}
	    			} else {
	    				col.levelTd.style.display = "none";
		    			col.treeTd.style.display = "none";
		    			if(!this.multiSelect) {
		    			    col.checkTd.style.display = "none";
		    			}
	    			}
    			}
    		} else {
    			var pl = cNode.level * 16 + 4;
	    		this._setNumberValue(col.levelTd, "width", pl);    			
	    		var rw = this._getNumberValue(col.levelDiv.style.width) - pl - this._getNumberValue(col.treeTd.style.width)
	    		    - this._getNumberValue(col.checkTd.style.width) - 4;
	    		if(rw <= 0) {
	    			rw = 40;
	    		}
	    		this._setNumberValue(col.rect, "width", rw);
	    		col.levelTd.level = cNode.level;
	    		if(hasfrozen) {
	    			this._setNumberValue(fcol.levelTd, "width", pl);
	    			this._setNumberValue(fcol.rect, "width", rw);
	    			fcol.levelTd.level = cNode.level;
	    		}
    		}
		},
		_refreshCheckCell:function(col, checkObj, enabled, cNode, colModel, fieldName, state) {
			if(checkObj.onoff == null) {
				//显示内容
				for(var i = 0, ilen = col.rect.text.childNodes.length; i < ilen; i++) {
					var cd = col.rect.text.childNodes[i];
					if(cd.nodeType < 3) {
						cd.style.display = "";
					}
				}
			} else {
				checkObj.onoff.show();
				checkObj.onoff.focus = false;
			}
			var vdab = enabled === false;
			if(checkObj.getDisable() != vdab) {
			    checkObj.setDisable(vdab);
			    if(checkObj.onoff != null) {
			    	if(vdab == true) {
			    		checkObj.onoff.disable();
			    	} else {
			    		checkObj.onoff.enable();
			    	}
			    	checkObj.onoff.refresh();
			    }
			}
			if(checkObj.getCheck() != state) {
			    checkObj.setCheck(state);
			    if(checkObj.getType() === "radio" && checkObj.getCheck() === true 
			    		&& this.radioCheck[fieldName] == null) {
			    	//缓存当前选择
					this.radioCheck[fieldName] = cNode;
			    }
			    if(checkObj.onoff != null) {
			    	if(state === true) {
			    	    checkObj.onoff.setState(1);
			    	} else {
			    		checkObj.onoff.setState(0);
			    	}
			    }
			}
			if(checkObj._option == null) {
			    checkObj._option = {};
			}
			var opt = checkObj._option;
			opt._this = this;
			opt._cNode = cNode;
			opt._fieldName = fieldName;
			opt._colModel = colModel;
			opt = null;
			
		},
		_bindCellEvent:function(col) {
			if(col != null && col.noUse !== true && col.onclick == null) {
				//选择事件
		    	col.onclick = this.doSelect;
		    	//双击事件
		    	col.ondblclick = this._ondbclick
		    	//鼠标事件 
		    	col.onmousedown = function(ev) {
		    		var ev = ev || event;
		    		this._option._this.doCellMouseDown(this, ev)
		    	}
		    	col.onmouseover = function(ev) {
		    		var ev = ev || event;
		    		this._option._this.doCellMouseOver(this, ev);
		    	}
			}
		},
		/**
		 * 获取所有列效验不符合要求的节点.
		 */
		validateAll:function(callBack) {
			this.dataSet.validateAll(callBack);
		},
		/**
		 * 显示效验的样式.
		 * @param colModel
		 * @param value
		 * @param node
		 * @param col
		 */
		refreshValidate:function(colModel, node, value, text, col) {
			if(this.isNotEmpty(colModel.validate)) {
				var co = this.dataSet.getCellOption(colModel.name, node);
				if(co.hasValidate !== true) {
					//初始化本来就有问题的数据.
					var valiShow = this.dataSet.validateValue(colModel.validate, node, colModel.name, value);
					if(!valiShow.state) {
						co.validateMessage = valiShow.message || colModel.validateMessage;
					} else {
						co.validateMessage = "";
					}
					co.hasValidate = true;
				}
				if(this.isNotEmpty(co.validateMessage)) {
					if(col.valiDiv == null) {
						col.valiDiv = this.createElement("DIV");
						this.setStyle(col.valiDiv, "validateCell");					
					}
					col.valiDiv.title = co.validateMessage;
					col.rect.appendChild(col.valiDiv);
					col.valiDiv.style.top = Math.round((this.rowHeight-20 - 8)/2) + "px";
				} else {
					if(col.valiDiv != null && col.valiDiv.parentNode == col.rect) {
						//ie8的时候typeof remove = "object"
						if(col.valiDiv.remove) {
	    				    col.valiDiv.remove();
	    				} else if(col.valiDiv.removeNode) {
	    					col.valiDiv.removeNode();
	    				}
					} 
				}		
			}
		},
	    /**
	     * 刷新单元格.
	     * @param {object} row 行元素
	     * @param {object} frow 冻结行元素
	     * @param {object} col 列元素
	     * @param {object} fcol 冻结列元素
	     * @param {number} rowIndex 行序号
	     * @param {number} colIndex 列序号
	     * @param {object} selNode 选择节点
	     * @param {boolean} gridReadOnly 表格只读
	     * @ignore
	     */
	    refreshCell:function(row, frow, col, fcol, prefzCol, rowIndex, colIndex, cNode, selNode, gridReadOnly, noCach) {
	    	var hasfrozen = fcol != null && fcol.noUse !== true; 
	    	var cellText = null;
	    	if(hasfrozen) {
	    		//冻结列及事件
	    		if(fcol._option._this == null) {
	    			fcol._option._this = this;
	    		}
	    		this._bindCellEvent(fcol);
	    		cellText = fcol.rect.text;
	    	} else {
	    		if(col._option._this == null) {
		    	    col._option._this = this;
		    	}
	    		this._bindCellEvent(col);
	    		cellText = col.rect.text;
	    	}
	    	//return 1.0  2ms
	    	if(colIndex === this._colOrder["@INDEX"]) {
	    		//return; //1.1 5ms
	    		if(this.getOption().rownumbers == false) {
	    			if(col.style.width !== "1px") {
		    			col.style.width = "1px";
		    			fcol.style.width = "1px";
	    			}
	    			return;
	    		} else {
	    			if(col.style.width !== "60px") {
		    			col.style.width = "60px";
		    			fcol.style.width = "60px";
	    			}
	    		}
	    		//序号列.
	    		var indexNum = this.dataSet.getIndex();
		    	this.setStyle(fcol, "treeListIndex");
		    	this.setStyle(col, "treeListIndex");
	    		if(this.getOption().pager && !isNaN(this.getPageSize())) {
	    			indexNum += this.getPageSize() * (this.getPageIndex() - 1);
	    		}
	    		this._setHtml(cellText, indexNum, false);
	    	} else if(colIndex === this._colOrder["@MUL"]) {
	    		//return;//1.8
	    		if(col.checkBox == null) return;	    		
    			var fieldName = "@MUL";    			
    			if(hasfrozen) {
    				this.setStyle(fcol, "treeListIndex");
    				this._refreshCheckCell(fcol, fcol.checkBox, cNode.enable == true, cNode, null, fieldName, cNode.checkState);
    				fcol.checkBox.bind("onClick", this._onTreeCheckBoxClick, true);
    				if(fcol.onclick != null) {
	    				fcol.onclick = null;
				    	fcol.ondblclick = null;
    				}
    			} else {
    				//this.setStyle(col, "treeListIndex");
        			this._refreshCheckCell(col, col.checkBox, cNode.enable == true, cNode, null, fieldName, cNode.checkState);
        			col.checkBox.bind("onClick", this._onTreeCheckBoxClick, true);
        			if(col.onclick != null) {
    	    			col.onclick = null;
    			    	col.ondblclick = null;
        			}
    			}
    			this.setStyle(col, "treeListIndex");
    			
    			//绘画背景，和字体颜色
		    	if(typeof this.onCellDraw === "function") {
		    		try {
		    			this.onCellDraw(this.dataSet, fieldName, fcol);
		    		} catch(e) {
		    			this.logInfo("call onCellDraw Error:" + e.message + e.stack);
		    		}		    		
		    	}
		    	this.trigger("onCellDraw_"+fieldName,[this.dataSet, fieldName, fcol]);
	    	} else {
	    		//return; //1.5 24ms
	    		//数据列
	    		var isFocusCell = (cNode.recNo === selNode.recNo && colIndex == this.colIndex);
	    		if(isFocusCell) {	    			
	    			if(hasfrozen) {
	    				this.curCell = fcol;
	    			} else {
	    				this.curCell = col;
	    			}
	    		}
	    		var cm = this._getColModel(colIndex);
	    		//处理隐藏
	    		if(cm.hidden) {
	    			if(col.style.display !== "none") {
			    		col.style.display = "none";
			    		if(hasfrozen) {
			    			fcol.style.display = "none";
			    		}
	    			}
		    		return;
		    	} else if(col.style.display == "none" && cm.groups !== true) {
		    		col.style.display = "";
		    		if(hasfrozen) {
		    			fcol.style.display = "";
		    		}
		    	}
	    		var fieldName = cm.name;
	    		if(cm.ellipsis !== false && cm.editType != "onoff" 
	    			&& cm.editType != "checkBox" && cm.editType != "radio") {
	    			this.addStyle(cellText, "ellipsis");
	    		}
	    		if($(cellText).css("textOverflow") == "ellipsis") {
	    			cellText.style.lineHeight = (this.rowHeight - 4) + "px";
	    		}
	    		//只读属性
	    		var colReadOnly = gridReadOnly;
	    		if(!colReadOnly) {
	    		    colReadOnly = this.getCellReadOnly(fieldName);
	    		}
	    		var cop = this._getCellOption(fieldName, noCach);
	    		var cellOption = cop.option;
	    		cellOption.disabled = this.getBooleanValue(cellOption.disabled, false);	    		
	    		//区域选择样式控制
	    		this._mulSelectStyle(col, fcol, prefzCol, cNode, selNode, rowIndex, colIndex, gridReadOnly, colReadOnly, isFocusCell, hasfrozen);
	    		//return //1.3 22ms
	    		var align = this.getColAlign(fieldName);
	    		var value = cop.value;
		    	var text = cop.text;
		    	//显示值
		    	var title = cellOption.title;
		    	//背景
		    	if(cellOption.bgColor != null) {		    		
		    		if(hasfrozen) {
		    			if(fcol.style.backgroundColor !== cellOption.bgColor) {
		    			    fcol.style.backgroundColor = cellOption.bgColor;
		    			}
		    		} else if(col.style.backgroundColor !== cellOption.bgColor) {
		    			col.style.backgroundColor = cellOption.bgColor;
		    		}	    		
		    	} else {		    		
		    		if(hasfrozen) {
		    			if(fcol.style.backgroundColor !== "") {
		    			    fcol.style.backgroundColor = "";
		    			}
		    		} else if(col.style.backgroundColor !== "") {
		    			col.style.backgroundColor = "";
		    		}
		    	}
		    	//字体
		    	if(cellOption.color != null) {		    		
		    		if(hasfrozen) {
		    			if(fcol.style.color !== cellOption.color) {
		    			    fcol.style.color = cellOption.color;
		    			}
		    		} else if(col.style.color !== cellOption.color) {
		    			col.style.color = cellOption.color;
		    		}	    		
		    	} else {		    		
		    		if(hasfrozen) {
		    			if(fcol.style.color !== "") {
		    			    fcol.style.color = "";
		    			}
		    		} else if(col.style.color !== ""){
		    			col.style.color = "";
		    		}
		    	}
		    	//标注
		    	if(title != null && title !== "") {		    		
		    		if(hasfrozen) {
		    			fcol.setAttribute("title", title);
		    			this.addStyle(fcol, "redInfo");
		    		} else {
		    			col.setAttribute("title", title);
			    		this.addStyle(col, "redInfo");
		    		}	    		
		    	} else {    		
		    		if(hasfrozen) {
		    			fcol.setAttribute("title", "");
		    		} else {
		    			col.setAttribute("title", "");
		    		}	
		    	}
		    	//显示勾稽提示
		    	if(cellOption.GJTitle != null && cellOption.GJTitle !== "") {
		    		
					if(hasfrozen) {
						var otitle = fcol.getAttribute("title");
						if(otitle === "" || otitle == null) {
			    			fcol.setAttribute("title", cellOption.GJTitle);		    		    
			    		} else {
			    			fcol.setAttribute("title", otitle + "\n" + cellOption.GJTitle);
			    		}
						this.addStyle(fcol, "redInfo");
					} else {
						var otitle = col.getAttribute("title");
						if(otitle === "" || otitle == null) {
			    			col.setAttribute("title", cellOption.GJTitle);		    		    
			    		} else {
			    			col.setAttribute("title", otitle + "\n" + cellOption.GJTitle);
			    		}
			    		this.addStyle(col, "redInfo");
					}
		    	}
		    	//显示
		    	if(cm.showHint == true) {
		    		var hintText = text;
		    		if(typeof hintText === "string") {
		    			if(hintText.indexOf("<") != -1) {
		    			    hintText = hintText.replace(/<(\/)?([a-zA-Z]+)( [^<>]+)?>/gi,"");
		    			}
		    			hintText = this._textToTag(hintText.trim());
		    		}
		    		if(hintText != null && hintText !== "") {			    		
						if(hasfrozen) {
							fcol.setAttribute("title", hintText + "\n" + fcol.title);
						} else {
							col.setAttribute("title", hintText + "\n" + col.title);
						}
		    		}
		    	}
		    	//return; //1.3 29ms
	    		if((this.getOption().treeKey == null && colIndex == 1||this.getOption().treeKey === fieldName) 
	    				&& this.option.treeGrid != false) {
	    			this._refreshTreeCol(col, fcol, hasfrozen, cNode, fieldName, text, value, isFocusCell, colReadOnly, cm);
	    		} else {
	    			if((cm.editType == "checkBox" || cm.editType == "onoff") && this.isNotEmpty(col.checkBox)) {	    					
	    	    		if(hasfrozen) {
	    	    			this._refreshCheckCell(fcol, fcol.checkBox, cellOption.disabled != true && cm.disabled !== true, cNode, cm, 
	    	    					fieldName, cm.editoptions.check == value);
	    	    			if(fcol.checkBox.hasbind("onClick")!== true) {
	    	    				fcol.checkBox.bind("onClick", this._onCommonCheckBoxClick, true);
	    	    			}
		    				if(fcol.style.textAlign !== align) {
				    		    fcol.style.textAlign = align;
				    		}	
		    				if(cm.editType == "onoff") {
		    					var ctn = fcol.checkBox.onoff.getControl()[0];
		    					if(align == "center") {
		    						ctn.style.marginLeft = "";
		    						ctn.style.margin = "auto";		    						
		    					} else if(align == "right") {
		    						ctn.style.margin = "";
		    						ctn.style.marginLeft = "auto";		    						
		    					} else {
		    						ctn.style.margin = "";
		    						ctn.style.marginLeft = "";
		    					}
		    					fcol.checkBox.onoff.bind("onclick", fcol.checkBox, function(checkBox, ev){
		    						checkBox.click();
		    						this.focus = false;
		    					}, true);
		    				}
					    } else {
					    	this._refreshCheckCell(col, col.checkBox, cellOption.disabled != true && cm.disabled !== true, cNode, cm, 
		    						fieldName, cm.editoptions.check == value);
		    				if(col.checkBox.hasbind("onClick") !== true) {
		    				    col.checkBox.bind("onClick", this._onCommonCheckBoxClick, true);
		    				}
		    				if(col.style.textAlign !== align) {
				    		    col.style.textAlign = align;
				    		}
		    				if(cm.editType == "onoff") {
		    					var ctn = col.checkBox.onoff.getControl()[0];
		    					if(align == "center") {
		    						ctn.style.marginLeft = "";
		    						ctn.style.margin = "auto";		    						
		    					} else if(align == "right") {
		    						ctn.style.margin = "";
		    						ctn.style.marginLeft = "auto";		    						
		    					} else {
		    						ctn.style.margin = "";
		    						ctn.style.marginLeft = "";
		    					}
		    					col.checkBox.onoff.bind("onclick", col.checkBox, function(checkBox, ev){
		    						checkBox.click();
		    						this.focus = false;
		    					}, true);
		    				}
					    }
	    	    		
	    	    		if(isFocusCell) {
	    					this.inputFocus = false;
	    				}
	    			} else if(cm.editType == "radio" && this.isNotEmpty(col.radio)) {	    					
	    	    		if(hasfrozen) {
	    	    			this._refreshCheckCell(fcol, fcol.radio, cellOption.disabled != true && cm.disabled !== true, cNode, cm, 
	    	    					fieldName, cm.editoptions.check == value);
	    	    			if(fcol.radio.hasbind("onClick") !== true) {
		    				    fcol.radio.bind("onClick",this._onCommonRadioClick, true);
	    	    			}
			    			if(fcol.style.textAlign !== align) {
				    		    fcol.style.textAlign = align;
			    			}			    			
					    } else {
					    	this._refreshCheckCell(col, col.radio, cellOption.disabled != true && cm.disabled !== true, cNode, cm, 
		    						fieldName, cm.editoptions.check == value);
					    	if(col.radio.hasbind("onClick") !== true) {
		    				    col.radio.bind("onClick",this._onCommonRadioClick, true);
					    	}
		    				if(col.style.textAlign !== align) {
				    		    col.style.textAlign = align;
				    		}
					    }
	    	    		if(isFocusCell) {
	    					this.inputFocus = false;
	    				}	    			
	    			} else {
	    				if(hasfrozen) {
	    					if(fcol.rect.style.display !== "") {
	    						this._resetCell(fcol);
		    				}	
	    				} else {
	    					if(col.rect.style.display !== "") {
		    					this._resetCell(col);
		    				}
	    				}
	    				if(isFocusCell) {
	    					this.inputFocus = false;
	    				}
	    			}
	    	    }
	    		if(hasfrozen) {
	    			this.refreshValidate(cm, cNode, value, text, fcol);
	    		} else {
	    		    this.refreshValidate(cm, cNode, value, text, col);
	    		}
	    		//return ;//1.2 46ms
		    	//绘画背景，和字体颜色
		    	if(typeof this.onCellDraw === "function") {
		    		try {
		    			if(hasfrozen) {
		    			    this.onCellDraw(this.dataSet, fieldName, fcol);
		    			} else {
		    				this.onCellDraw(this.dataSet, fieldName, col);
		    			}
		    		} catch(e) {
		    			this.logInfo("call onCellDraw Error:" + e.message + e.stack);
		    		}		    		
		    	}
		    	if(hasfrozen) {
		    	    this.trigger("onCellDraw_"+fieldName,[this.dataSet, fieldName, fcol]);
		    	} else {
		    		this.trigger("onCellDraw_"+fieldName,[this.dataSet, fieldName, col]);
		    	}
		    	/**
		    	 * 字段格式化.
		    	 */
		    	if(this.hasbind("onFormat_" + fieldName)) {
		    		text = this.trigger("onFormat_" + fieldName, [this.dataSet, fieldName, text, value]);
		    	}
		    	//return;
		    	//return;//1
	    		//设置对齐样式，
	    	    if(!(isFocusCell && !colReadOnly 
	    	    	&& this.focus && !this.mulCellSelect)  
    					&& cm.editType != "checkBox" 
    						&& cm.editType != "radio"
    							&& cm.editType != "onoff") {
	    	    	if(this.isNotEmpty(cellOption.link)) {
	    	    		text = "<a href='" + cellOption.link + "'>" + text + "</a>"
	    	    	}
	    	    	
    	    		if(hasfrozen) {
		    			if(fcol.style.textAlign !== align) {
			    		    fcol.style.textAlign = align;
		    			}
				    } else if(col.style.textAlign !== align) {
		    		    col.style.textAlign = align;
		    		}
    	    		if(cm.link === true && colReadOnly === true) {
                    	if(cellText.al == null) {
                    	    cellText.al = this.createElement("span");
                    	    var _this = this;
                    	    //用onclick的话，焦点不在的时候事件不起作用。
                    	    cellText.al.onmouseup = function() {
                    	    	var cn = _this.dataSet.getCurNode();
                    	    	_this.dataSet.beginUpdate();
                    	    	_this.dataSet.select(this._node);
    	    	    			this._node.option[fieldName].linkClick = true;
    	    	    			if(_this.trigger("onLinkClick", [_this, this._fieldName, this._node]) !== false) {
    	    	    			    _this.dataSet.select(cn);
    	    	    			}
    	    	    			_this.dataSet.endUpdate(false);
    	    	    		}                    	    
                    	}
                    	if(cNode.option[fieldName].linkClick === true) {                    	    	
                	    	this.setStyle(cellText.al, "link_visited");
                	    } else {
                    	    this.setStyle(cellText.al, "link");
                	    }
                    	cellText.al.style.display = "";
                    	cellText.al._node = cNode;
                    	cellText.al._fieldName = fieldName;
                    	cellText.al.id = this.dataSet.getIndex();	    	    		
	    	    		this._setHtml(cellText, "");
	    	    		//this._addChild(cellText, cellText.al);
	    	    		cellText.appendChild(cellText.al);
	    	    		this._setHtml(cellText.al, text, false);
	    	    	} else {	    	    	
	    	    		if(cellText.innerHTML !== text) {
	    	    			this._setHtml(cellText, text, false);
	    	    		}
	    	    	}	    	    	
	    		}
	    	}
	    },
	    /**
	     * 计算冻结列的宽度.
	     */
	    _refreshFzTitleWidth:function() {
	        var fzSum = 0;
	        //计算长度的时候，要把隐藏列去掉.
			for(var j = 0, len = this.fzGridTable.rows[0].cells.length; j < len; j++) {
				var td = this.fzGridTable.rows[0].cells[j];
				if(td.style.display != "none") {
					fzSum += this._getNumberValue(td.style.width);
				}				
			}
			this.fzGridTable.style.width = fzSum + "px";
        },
	    _setGridTableWidth:function(width) {
	    	this.gridTable.style.width = width + "px";
	    	this.listDivBox.style.width = "100%";
	    	this._refreshFzTitleWidth();
	    	
	    	this.fzSumTable.style.width = this.fzGridTable.style.width;
	    	this.sumTable.style.width = this.gridTable.style.width;
	    },
	    /**
	     * 隐藏合计行的单元格.
	     * @param rowinex 行号
	     * @param cellIndex 列号
	     * @param width 宽度
	     * @param borderWidth 边线宽
	     * @param display 显示
	     */
	    _hideTotalCell:function(rowindex, cellIndex, width, borderWidth, display) {
	    	var scls = this.sumTable.rows[rowindex].cells[cellIndex];
    		scls.style.width = width;
    		scls.style.borderRightWidth = borderWidth;
    		scls.rect.style.display = display;
    		scls = this.fzSumTable.rows[rowindex].cells[cellIndex];
    		scls.style.width = width;
    		scls.style.borderRightWidth = borderWidth;
    		scls.style.display = display;
    		scls = null;
	    },
	    /**
	     * 刷新隐藏状态.
	     */
	    refreshHiddenState:function() {
	    	var gridWidth = 60;
	    	var fns = [];
	    	var scls = null;
	    	var index = this._colOrder["@INDEX"];
		    if(this.getOption().rownumbers) {		    	
		    	var cc = this.gridTable.rows[0].cells[index];
		    	cc.style.display = "";
		    	cc.style.width = "60px";
		    	this.fzGridTable.rows[0].cells[index].style.display = "";
		    	this.fzGridTable.rows[0].cells[index].style.width = "60px";
		    	if(this.getOption().footerrow === true || this.getOption().total === true) {
		    		this._hideTotalCell(this.totalIndex, index, "60px", "","");
		    	}
		    	if(this.getOption().subtotal === true) {
		    		this._hideTotalCell(this.subtotalIndex, index, "60px", "","");
		    	}
	    		this.gridTable.rows[1].cells[index].style.display = "";
	    		this.gridTable.rows[1].cells[index].style.width = "60px";
	    		this._setHtml(this.gridTable.rows[1].cells[index], this.numberCaption);
		    	this.fzGridTable.rows[1].cells[index].style.display = "";
		    	this.fzGridTable.rows[1].cells[index].style.width = "60px";
		    	this._setHtml(this.fzGridTable.rows[1].cells[index], this.numberCaption);
		    	for(var i = this.titleRowCount, rlen = this.gridTable.rows.length; i < rlen; i++) {
		    		var cc = this.gridTable.rows[i].cells[index];		    	
		    		cc.style.width = "60px";
		    		cc.style.display = "";
		    		var fcc = this.fzGridTable.rows[i].cells[index];
		    		fcc.style.width = "60px";
		    		fcc.style.display = "";
		    	}
	    	} else {
	    		this.gridTable.rows[0].cells[index].style.display = "none";
	    		this.gridTable.rows[0].cells[index].style.width = "1px";
		    	this.gridTable.rows[1].cells[index].style.display = "none";
		    	this.fzGridTable.rows[0].cells[index].style.display = "none";
		    	this.fzGridTable.rows[0].cells[index].style.width = "1px";	
		    	this.fzGridTable.rows[1].cells[index].style.display = "none";
		    	if(this.getOption().footerrow === true || this.getOption().total === true) {
		    		this._hideTotalCell(this.totalIndex, index, "1px", "0px", "none");
		    	}
		    	if(this.getOption().subtotal === true) {
		    		this._hideTotalCell(this.subtotalIndex, index, "1px", "0px", "none");
		    	}
		    	//this.fzGridTable.rows[1].cells[index].style.height = (this.gridTable.rows[1].cells[index].offsetHeight + this._addDeff(this.titleRowCount - 1)) + "px";
		    	this.setStyle(this.fzGridTable.rows[1].cells[index], "gridNoneCell");
		    	this.setStyle(this.gridTable.rows[1].cells[index], "gridNoneCell");
		    	for(var i = this.titleRowCount, rlen = this.gridTable.rows.length; i < rlen; i++) {
		    		var cc = this.gridTable.rows[i].cells[index];	
		    		cc.style.display = "none";
		    		this.setStyle(cc, "gridNoneCell");
		    		var fcc = this.fzGridTable.rows[i].cells[index];
		    		//在ie8下，会被撑开,因此还是要隐藏一下，
		    		fcc.style.display = "none";
		    		this.setStyle(fcc, "gridNoneCell");
		    	}	
		    	fns.push("@INDEX");
		    	gridWidth = 0;
	    	};
	    	if(this._hasCheckCol && this.treeGrid == false) {
	    		var index = this._colOrder["@MUL"];
	    		if(this.multiSelect) {	    			
	    			var cc = this.gridTable.rows[0].cells[index];
			    	cc.style.width = "30px";
			    	this.fzGridTable.rows[0].cells[index].style.width = "30px";
			    	if(this.getOption().footerrow === true || this.getOption().total === true) {
			    		this._hideTotalCell(this.totalIndex, index, "30px", "", "");
			    	}
			    	if(this.getOption().subtotal === true) {
			    		this._hideTotalCell(this.subtotalIndex, index, "30px", "", "");
			    	}
		    		this.gridTable.rows[1].cells[index].style.width = "30px";
		    		if(this.gridTable.rows[1].cells[index].checkBox != null) {
		    		    this.gridTable.rows[1].cells[index].checkBox.show();//style.display = "";
		    		}
			    	this.fzGridTable.rows[1].cells[index].style.width = "30px";	
			    	if(this.fzGridTable.rows[1].cells[index].checkBox != null) {
			    	    this.fzGridTable.rows[1].cells[index].checkBox.show();//style.display = "";
			    	}
			    	for(var i = this.titleRowCount, rlen = this.gridTable.rows.length; i < rlen; i++) {
			    		var cc = this.gridTable.rows[i].cells[index];		    	
			    		cc.style.width = "30px";
			    		cc.rect.style.display = "";
			    		var fcc = this.fzGridTable.rows[i].cells[index];
			    		fcc.style.width = "30px";
			    		fcc.rect.style.display = "";
			    	}
			    	gridWidth += 30;
	    		} else {	    			
	    			this.gridTable.rows[0].cells[index].style.width = "1px";
			    	this.gridTable.rows[1].cells[index].style.width = "1px";
			    	if(this.gridTable.rows[1].cells[index].checkBox != null) {
			    	    this.gridTable.rows[1].cells[index].checkBox.hide();//style.display = "none";
			    	}
			    	this.fzGridTable.rows[0].cells[index].style.width = "1px";		    	
			    	this.fzGridTable.rows[1].cells[index].style.width = "1px";
			    	if(this.fzGridTable.rows[1].cells[index].checkBox != null) {
			    	    this.fzGridTable.rows[1].cells[index].checkBox.hide();//style.display = "none";
			    	}
			    	if(this.getOption().footerrow === true || this.getOption().total === true) {
			    		this._hideTotalCell(this.totalIndex, index, "1px", "0px", "none");
			    	}
			    	if(this.getOption().subtotal === true) {
			    		this._hideTotalCell(this.subtotalIndex, index, "1px", "0px", "none");
			    	}
			    	//this.fzGridTable.rows[1].cells[0].style.height = (this.gridTable.rows[1].cells[0].offsetHeight + this._addDeff(this.titleRowCount - 1)) + "px";
			    	this.setStyle(this.fzGridTable.rows[1].cells[index], "gridNoneCell");
			    	this.setStyle(this.gridTable.rows[1].cells[index], "gridNoneCell");
			    	for(var i = this.titleRowCount, rlen = this.gridTable.rows.length; i < rlen; i++) {
			    		var cc = this.gridTable.rows[i].cells[index];		    	
			    		cc.style.width = "1px";
			    		cc.rect.style.display = "none";
			    		this.setStyle(cc, "gridNoneCell");
			    		var fcc = this.fzGridTable.rows[i].cells[index];
			    		fcc.style.width = "1px";
			    		fcc.rect.style.display = "none";
			    		this.setStyle(fcc, "gridNoneCell");
			    	}	
			    	fns.push("@INDEX");
			    	//gridWidth = 0;
	    		}
	    	}
	    	//gridWidth += this.mulCellWidth;
	    	
	    	var colModel = this.option.colModels;
	    	for(var j = 0, clen = colModel.length; j < clen; j++) {
	    		var cm = colModel[j];
	    		if(cm.hidden) {
	    			fns.push(cm.name);
	    		}	    		
	    	}
	    	var fns = fns.join(",");
	    	if(this.hiddenFieldNames === fns) {
	    		return
	    	}
	    	this.hiddenFieldNames = fns;
	    	var minRowSpan = this.titleRowCount;
	    	for(var j = 1, clen = this.titleCol.length; j <= clen; j++) {
	    		var cm = colModel[j - 1];
	    		var col = this.titleCol[j - 1];
	    		if(cm.hidden) {	    			
	    			if(col.style.display != "none") {
		    			col.style.display = "none";
		    			var bri = col.option.bandRowIndex;
		    			var bci = col.option.bandColIndex;
		    			//循环处理所有层次的隐藏
		    			while(this.isNotEmpty(bri) && bri > 0) {
		    				if(bri == 1) {
		    					bci ++;
		    					bci += this._colIndexDeff();
		    				}
		    				var tcol = this.gridTable.rows[bri].cells[bci];
		    				if(tcol.getAttribute("colSpan") <= 1) {
		    					tcol.style.display = "none";
		    				} else {
		    					tcol.setAttribute("colSpan", parseInt(tcol.getAttribute("colSpan"), 10)- 1);
		    				}
		    				if(this.isNotEmpty(col.mainCell)) {
		    					//有冻结列
		    					var mcol = this.fzGridTable.rows[bri].cells[bci];
			    				if(mcol.getAttribute("colSpan") <= 1) {
			    					mcol.style.display = "none";
			    				} else {
			    					mcol.setAttribute("colSpan", parseInt(mcol.getAttribute("colSpan"),10)- 1);
			    				}
		    				}
		    				bri = tcol.option.bandRowIndex;
		    				bci = tcol.option.bandColIndex;
		    			}
	    			}	    			
	    		} else if(col.style.display != ""){
	    			//还原显示隐藏列
	    			col.style.display = "";
	    			var bri = col.option.bandRowIndex;
	    			var bci = col.option.bandColIndex;
	    			//循环还原显示所有隐藏列
	    			while(this.isNotEmpty(bri) && bri > 0) {
	    				if(bri == 1) {
	    					bci ++;
	    					bci += this._colIndexDeff();
	    				}
	    				var tcol = this.gridTable.rows[bri].cells[bci];
	    				if(tcol.getAttribute("colSpan") < 1 || tcol.style.display === "none") {	  
	    					tcol.style.display = "";
	    					tcol.setAttribute("colSpan", 1);
	    				} else {
	    					tcol.setAttribute("colSpan", parseInt(tcol.getAttribute("colSpan"), 10) +  1);
	    				}
	    				if(this.isNotEmpty(col.mainCell)) {
	    					//有冻结列
	    					var mcol = this.fzGridTable.rows[bri].cells[bci];
		    				if(mcol.getAttribute("colSpan") < 1 || mcol.style.display === "none") {	
		    					mcol.style.display = "";
		    					mcol.setAttribute("colSpan", 1);
		    				} else {
		    					mcol.setAttribute("colSpan", parseInt(mcol.getAttribute("colSpan"), 10) + 1);
		    				}
	    				}
	    				bri = tcol.option.bandRowIndex;
	    				bci = tcol.option.bandColIndex;
	    			}
	    		}
	    		if(!cm.hidden) {
	    			gridWidth += this.getColWidth(j + this._colIndexDeff(),0);
	    			var crsp = col.getAttribute("rowSpan");
	    			if(crsp != null && crsp !== "") {
	    				crsp = parseInt(crsp, 10);
	    			} else {
	    				crsp = 1;
	    			}
	    			if(crsp < minRowSpan) {
	    				minRowSpan = crsp;
	    			}
	    		}
	    		
	    		//隐藏处理冻结列
	    		if(this.isNotEmpty(col.mainCell)) {
	    			if(col.mainCell.style.display != col.style.display) {
	    			    col.mainCell.style.display = col.style.display;
	    			}
	    			if(this.fzGridTable.rows[0].cells[j + this._colIndexDeff()].style.display != col.style.display) {
	    				this.fzGridTable.rows[0].cells[j + this._colIndexDeff()].style.display = col.style.display;
	    			}
	    			//重新设置列宽度
	    			if(col.mainCell.style.display != "none" && this.gridTable.rows[0].cells[j + this._colIndexDeff()] != null) {
	    				this.gridTable.rows[0].cells[j + this._colIndexDeff()].style.width = this.fzGridTable.rows[0].cells[j + this._colIndexDeff()].style.width;
	    			}
	    		}
	    		if(this.gridTable.rows[0].cells[j + this._colIndexDeff()].style.display != col.style.display) {
	    		    this.gridTable.rows[0].cells[j + this._colIndexDeff()].style.display = col.style.display;
	    		}
	    	}//for
	    	//
	    	if(minRowSpan > 1) {
	    		if(this.zipTitleHeight !== true) {
	    			//压缩
		    		var smm = minRowSpan - 1;
		    		for(var j = 1, clen = this.titleCol.length; j <= clen; j++) {
			    		var cm = colModel[j - 1];
			    		var col = this.titleCol[j - 1];
			    		if(!cm.hidden) {
			    			var rsp = this._getNumberValue(col.getAttribute("rowSpan"), 1) - smm;
			    			if(rsp <= 0) {
			    				rsp = 1;
			    			}
			    			var ch = rsp * this.rowHeight;
		    				col.style.height = ch + "px";
		    				if(this.isNotEmpty(col.mainCell)) {
		    					var fcol = col.mainCell;
		    					fcol.style.height = ch + "px";
		    				}
			    		}
		    		}
		    		//顶慰配置一下行高.
		    		this.gridTable.rows[1].style.height = this.rowHeight + "px";
		    		this.zipTitleHeight = true;
		    		this.initGrid();
	    		}
	    	} else {
	    		if(this.zipTitleHeight == true) {
	    			//还原
	    			for(var j = 1, clen = this.titleCol.length; j <= clen; j++) {
			    		var cm = colModel[j - 1];
			    		var col = this.titleCol[j - 1];
			    		if(!cm.hidden) {
			    			var rsp = this._getNumberValue(col.getAttribute("rowSpan"), 1);
			    			if(rsp <= 0) {
			    				rsp = 1;
			    			}
			    			var ch = rsp * this.rowHeight;
		    				col.style.height = ch + "px";
		    				if(this.isNotEmpty(col.mainCell)) {
		    					var fcol = col.mainCell;
		    					fcol.style.height = ch + "px";
		    				}
			    		}
		    		}
	    			this.gridTable.rows[1].style.height = "";
	    			this.zipTitleHeight = false;
	    			this.initGrid();
	    		}	    		
	    	}
	    	colModel = null;
	    	scls = null;
	    	//this.gridTable.style.width = gridWidth + "px";
	    	this._setGridTableWidth(gridWidth);
	    	this._asynRun(function(){
	    	    if(this.thisWindow.offsetWidth > 0) {
	    	        this._suitTitleHeight();
	    	    }
	    	}, 0);
	    },
	    /**
	     * 刷新排序状态.
	     */
	    refreshSortState:function(fieldName) {
	    	if(fieldName == null) {
	    	    fieldName = this.getFieldName();
	    	}
	    	var sortTable = this.sortTables[fieldName];
	    	var cm = this.getColModel(fieldName);
	    	if((this.getOption().filter != false || this.getOption().sort !== false) && 
	    			sortTable != null && cm.filter != false) {
	    		sortTable.colIndex = this.colIndex;
	    		sortTable.style.display = "";			    
			    var isFilter = this.dataSet.getFilterState(fieldName);
			    sortTable.filtered = isFilter;
			    if(this._sortFieldName == fieldName) {
			    	//显示排序状态
			    	if(sortTable.sortState == "none") {
			    		//没有排序.
			    	    if(this.dataSet.filtered && isFilter) {
			    	    	this.setStyle(sortTable.sortIcon, "filter");
			    	    } else {	    	    	    
		        		    this.setStyle(sortTable.sortIcon, "sortDefault");
			    	    }
		        	} else if(sortTable.sortState == "up") {
		        		//向上排序
		        	    if(this.dataSet.filtered && isFilter) {
		        	    	this.setStyle(sortTable.sortIcon, "filterUp");
		        	    } else if(this.getOption().filter === false || cm.filter === false) {
		        	    	this.setStyle(sortTable.sortIcon, "sortUpOnly");
		        	    } else {
		        		    this.setStyle(sortTable.sortIcon, "sortUp");
		        	    }
		        	} else if(sortTable.sortState == "down") {
		        		//向下排序
		        	    if(this.dataSet.filtered && isFilter) {
		        	    	this.setStyle(sortTable.sortIcon, "filterDown");
		        	    } else if(this.getOption().filter === false || cm.filter === false) {
		        	    	this.setStyle(sortTable.sortIcon, "sortDownOnly");
		        	    } else {
		        		    this.setStyle(sortTable.sortIcon, "sortDown");
		        	    }
		        	}
			    	sortTable.state = sortTable.sortState;
			    } else {
			    	//没有排序.
		    	    if(this.dataSet.filtered && isFilter) {
		    	    	if(this.getOption().sort === false || cm.sort === false) {
		    	    		this.setStyle(sortTable.sortIcon, "filterOnly");
		    	    	} else {
		    	    	    this.setStyle(sortTable.sortIcon, "filter");
		    	    	}
		    	    } else {	    	    	    
		    		    this.setStyle(sortTable.sortIcon, "sortDefault");
		    	    }
		    	    sortTable.state = "none";
			    }
			}
	    	//是否都不显示
	    	hideSort = this.getOption().filter === false && this.getOption().sort === false;
	    	//隐藏其它列的属性
	    	for(var key in this.sortTables) {
	    		var st = this.sortTables[key];
	    		if(key !== fieldName || hideSort) {
	    			if(st.filtered != true) {
	    				st.style.display = "none";
    	    		}
	    			if(key != this._sortFieldName && st != null && st.sortState != "none") {
	    				st.sortState = "none";
	    			}
	    		}
	    		st = null;
	    	}
	    },
	    /**
	     * 刷新滚动条.
	     */
	    refreshScrollBar:function() {
	    	var len = this.dataSet.getVisibleCount();
	    	var footerrow = this.getOption().footerrow === true || this.getOption().total === true;
			var sc = 0;
			if(this.hafRow) {
				sc ++;
				if(this.getOption().subtotal === true) sc++;
			}
            var gw = this._getNumberValue(this.gridTable.style.width, 0);	
            if(this._addNew) {
				if(this.getOption().width - gw < 18 && this.getOption().width > gw && this.scrollBar.visible == false) {
					if(this.rowCount - sc + 1 == len) {
						this.rowCount -- ;
						this._asynRun(function(){
							if(this.scrollBar != null) {
								this.scrollBar.scrollNext();
							}
						}, 50)
					}
				} else if(this.bottomNode != null 
						&& this.bottomNode.scrIndex == len
						  && this.bottomNode.recNo === this.dataSet.getCurNode().recNo) {
					this._asynRun(function(){
						if(this.scrollBar != null) {
							this.scrollBar.scrollNext();
						}
					}, 50)
			    }
            }
	    	if(this.visibleCount != len || this.rowCount - sc != this.scrollBar.visibleCount) {
	    		if(this.rowCount - sc < len) { 
	    			var ishide = this.getHScrollHide();
	    			this.scrollBar.setVisible(true);
	    			if(ishide === true && this.getHScrollHide() === false) {
	    				this.rowCount--;
	    			}
	    			this.scrollBar.setScrollCount(len, this.rowCount - sc);
	    		} else {
	    			if(this.topNode != null && this.topNode.level === 0 && this.topNode.index === 0) {
	    				this.topNode.scrIndex = 1;
	    			}
	    			//刚好收到没有滚动条时，往顶滚动
	    			if(this.dataSet.getRecordCount() > 0 && this.topNode != null && this.topNode.scrIndex > 1) {
						this.topNode = this.dataSet.getChildNode(0, this.dataSet.rootNode);
						this.topNode.scrIndex = 1;
						this.refresh();
					}
	    			this.scrollBar.scrollIndex = 0;
	    			this.scrollBar.setScrollCount(0, 0);
	    			this.scrollBar.setVisible(false);
	    		}
	    		this.visibleCount = len;
	    	} else if(this.visibleCount == 0){
	    		this.scrollBar.setVisible(false);
	    	}
	    	this.base();
	    },
	    getPageIndex:function() {
	    	return this.pageObj.getPageIndex();
	    },
	    getPageSize:function() {
	    	return this.pageObj.getPageSize();
	    },
	    getPageCount:function() {
	    	return this.pageObj.getPageCount();
	    },
	    /**
	     * 获取数据模型.
	     * 缺省状态下返回所有显示的列colModel
	     * @param fieldName 字段名称
	     * 
	     */
	    getColModel:function(fieldName) {
	    	 if(fieldName == null) {
	    		 var recm = [];
	    		 for(var i = 0, len = this.option.colModels.length; i < len; i++) {
		    			var cm = this.option.colModels[i];
		    			if(cm.hidden != true) {
		    				recm.push({dataType:cm.dataType,style:this.getColAlign(cm.name)});
		    			}
		    	}
	    		return recm;
	    	 } else {
	    		 return this.option.colModelJson[fieldName];
	    	}
	    },
	    /**
	     * 获取colModel
	     * @name _getColModel
	     * @ignare
	     */
	    _getColModel:function(index) {
	    	return this.option.colModels[index - 1 - this._colIndexDeff()] || {};
	    },
	    /**
	     * 获取当前选择列字段.
	     * @return 返回当前列字段
	     */
	    getFieldName:function(index) {
	    	 if(index == null) {
	    		 index = this.colIndex;
	    	 }
	    	 return this._getColModel(index).name;
	    },

	    /**
	     * 设置容器.
	     * @param value 容器
	     */
	    setContainer:function(value) {
	    	this.container = value;
	    },
	    /**
	     * 结束刷新.
	     */
	    endUpdate:function(ref) {
	    	this._update = true;
	    	if(ref !== false) {
	    	    this.refresh();
	    	}
	    },
	    /**
	     * 保存变更集.
	     * @param key 保存主键
	     */
	    saveChangeSet:function(key) {
	    	if(key == null || key === "") {
	    		return false;
	    	}
	    	//处理旧的缓存
	    	if(this._cacheKey != null && this._cacheKey !== "") {
	    		if(this._cacheChangeSet == null) {
	    			this._cacheChangeSet = {};
	    		}
	    		this._cacheChangeSet[this._cacheKey] = this.getChangeSet(true);
	    		if(this._cacheEcpChangeSet == null) {
	    			this._cacheEcpChangeSet = {};
	    		}
	    		this._cacheEcpChangeSet[this._cacheKey] = this.getEcpChangeSet(true);
	    	}
	    	//设置新的值
	    	this._cacheKey = key;
	    },
	    /**
	     * 加载脏数据包.
	     * @param key
	     * @param callBack
	     */
	    loadChangeSet:function(callBack) {
	    	if(this._cacheKey != null && this._cacheKey !== "") {	    		
	    		var cacheData = this._cacheChangeSet[this._cacheKey];
	    		if(this._cacheChangeSet != null && cacheData != null) {
	    			var key = this.getOption().idkey;
	    			var cjson = {};
	    			var njson = [];
	    			var pnodes = {};
	    			var cindex = {};
	    			for(var i = 0, ilen = cacheData.length; i < ilen; i++) {
	    				var cd = cacheData[i];
	    				if((cd.modelState & this.dataSet.modelState.NEW) > 0) {	    	    		
	    					njson.push(cd);
	    					cindex[cd._index] = true;
	    					if(this.getOption().pidkey != null) {
	    						pnodes[cd[this.getOption().pidkey]] = true;
	    					}
	    				} else {
	    					cjson[cd[key]] = cd;
	    				}
	    			}
	    			//还原变更状态
	    			this.dataSet.each(function(node) {
	    				var kv = this.getValue(this.getOption().idkey, node);
	    				var cd = cjson[kv];
	    				if(cd != null) {
	    					var ms = cd.modelState;
	    					if((ms & this.modelState.DELETE) > 0) {
	    						this.delRecord(node);
	    					} else if((ms & this.modelState.MODIFY) > 0) {
	    						var ov = cd._oldValue;
	    						for(var key in ov) {
	    							this.setValue(key, cd[key]);
	    						}
	    					}
	    					//缓存父节点.
	    					if(this.getOption().pidkey != null
	    							&& this.getOption().pidkey !== "") {
	    						var pkey = this.getValue(this.getOption().pidkey);
	    						if(pnodes[pkey] === true) {
	    							pnodes[pkey] = node;
	    						}
	    					}
	    				}
	    			}, 
	    			function() {
	    				//把新增的添加到指定的树节点下面
	    				for(var i = 0, ilen = njson.length; i < ilen; i++) {
	    					var cd = njson[i];
	    					var index = cd._index;
	    					var pnode = this.dataSet.rootNode;
	    					if(this.getOption().pidkey != null 
	    							&& this.getOption().pidkey !== "") {
	    						pnode = pnodes[cd[this.getOption().pidkey]];
	    					}
	    					if(index > pnode.getCount() - 1) {
	    						//添加
	    						this.dataSet.appendItem(cd, pnode);	
	    					} else {
	    						//直接插入，没有考虑index超出情况.
	    						this.dataSet.insertItem(index, cd, pnode);
	    					}
	    				}
	    				//执行回调
	    				if(typeof callBack == "function") {
	    					callBack.apply(this);	
	    				}	    	    	
	    			});
	    		} else {
	    			//执行回调
					if(typeof callBack == "function") {
						callBack.apply(this);	
					}
	    		}
	    	} else {
	    		//执行回调
				if(typeof callBack == "function") {
					callBack.apply(this);	
				}
	    	}
	    },
	    /**
	     * 初始化表格数据.
	     * @param value 数据集
	     */
	    initValue:function(value, sortState, changeSetKey, callBack) {
	    	try{
	    	    if(this._hasDestroy == true) return;
	    		if(this.rendered != true) {
	    			return;
	    		} 
	    		if(this._lockValue == true) {
	    			if(typeof this._icpData == "function") {
	    				this._icpData(value);
	    			}
	    			return;
	    		}
	    		var sorttype = typeof sortState;
	    		if(sorttype == "function") {
	    			callBack = sortState;
	    			sortState = null;
	    		} else if(sorttype == "string") {
	    			changeSetKey = sortState;
	    			sortState = null;
	    		} else if(typeof changeSetKey == "function") {
	    			callBack = changeSetKey;
	    			changeSetKey = null;
	    		}
		    	var _this = this;
	    		this.dataSet.initSort = (sortState == null || sortState) && this.treeGrid != false
	    		　　　　　　&& this.getOption().initSort !== false;
	    		this.dataSet.isTree = this.treeGrid != false;
	    		this.dataSet.clearFilterText();
	    		var treeId = this.getOption().treeId || this.getOption().idkey || this.getOption().idKey;
	    		if(treeId == null) {
	    			treeId = this.getPKeyName();
	    		}
	    		this.dataSet.getOption().idkey = treeId;
	    		
	    		var treePid = this.getOption().parentKeyId || this.getOption().pidkey || this.getOption().pidKey;
		    	if(this.getOption().treePidData || treePid != null && treePid !== "") {
		    		//默认不排序
		    		this.dataSet.initSort = false;
		    		this.dataSet.setIDPID(treeId, treePid);
		    	} else {		    		
		    		this.dataSet.setItemCode(treeId);
		    	}
		    	if(this.multiSelect) {
		    		this.setTitleChecked("@MUL", false);
		    	}
		    	var hasFirst = false;
		    	//还原排序设置
	    		for(var key in this.sortTables) {
	    			this.sortTables[key].sortState = "none";
	    		}
	    		//还原转换状态
	    		if(this.transState != null) {
	    			for(var key in this.transState) {
	    				this.transState[key].transed = false;
	    			}
	    		}
	    		//清除单选列的缓存
	    		this.radioCheck = {};
	    		//清空控件缓存
	    		this.editObjects = {};
	    		this.editObject = null;
	    		this._lockDestroy = true;
	    		//配置了缓存，且有配置分页的情况
	    		if((changeSetKey == null || changeSetKey === "") 
	    			&& this.getOption().cacheChangeSet === true 
	    				&& this.getOption().pager === true) {
	    			changeSetKey = this.getPageSize() + "_" + this.getPageIndex();
	    		}
	    		if(changeSetKey != null && changeSetKey !== "") {
	    		    this.saveChangeSet(changeSetKey);
	    		}
	    		//清除上一次内容自适应内容。
	    		this.initMaxText();
		    	//初始化数据
		    	this.dataSet.setItemList(value, function(){
                    if(_this.gridTable == null || _this.gridTable.rows.length == 0) return;
		    		if(_this.getOption().pager) {
			        	//_this.pageObj.setTotalCount(200);			        	
		    		}
		    		//外部样式控制外框时，自适应一下
		    		var ofw = _this._getNumberValue(_this.thisWindow.style.width, _this.getOption().width);
					if(ofw > 0 && (ofw > _this.getOption().width + 2 || ofw < _this.getOption().width)) {
						_this.setWidth(ofw);
					}
					//不知道为什么要初始化一次.
					//_this.initGrid();
					_this.refreshScrollBar();
		    		var cms = _this.option.colModels;
		    		var cffn = [],ctfn = [];
		    		for(var i = 0, len = cms.length; i < len; i++) {
		    			var cm = cms[i];
		    			if(cm.contentFit === true) {
		    				cffn.push(cm.name);
		    			}
		    			if(cm.titleFit === true) {
		    				ctfn.push(cm.name);
		    			}
		    		}
		    		cms = null;
		    		var _that = _this;
		    		if(_this.getOption().isExpanded == false) {
		    			_this.dataSet.fullCollapse(function(){		    						    			
		    				if(_that.getOption().defSelect) {
		    				    _that.first();
		    				} else {
		    				    _that.noSelect();
		    				}	
		    				if(_that.getOption().suitToFit === true) {
		    					_that.suitToFit();
		    		        }
		    				_that = null;
		    			});
		    			
		    		}
		    		_this.dataSet.caculateSum(true);
		    		//_this.refresh();
                    if(_this.gridTable == null || _this.gridTable.rows.length == 0) return;
                    if(_this.getOption().defSelect) {
                    	_this.first();
    				} else {
    					_this.noSelect();
    				}	
		    		_this._tmpScrollVisible = null;
		    		if(ctfn.length > 0) {
		    			_this.setTitleFit(ctfn, null);
		    		}
		    		//宽度自适应
		    		if(cffn.length > 0) {
		    		    _this.setContentFit(cffn, undefined, function() {
		    		    	if(this.getOption().shrinkToFit !== false && this.gridTable.rows.length > 0) {
		    		    		this.shrinkToFit();
		    		        }
		    		    	if(this.getOption().suitToFit === true) {
		    		    		this.suitToFit();
		    		        }
		    		    });
		    		} else {
		    			if(_this.getOption().shrinkToFit !== false) {
	    		    		_this.shrinkToFit();
	    		        }
		    			if(_this.getOption().suitToFit === true) {
	    		    		_this.suitToFit();
	    		        }
		    		}
		    		//初始化后事件
		    		if(typeof _this.onAfterLoad == "function") {
		    			try {
		    				_this.onAfterLoad();
		    				
		    			} catch(e) {
		    				_this.logInfo("[onAfterLoad] error:" + e.message + e.stack);
		    			}
		    		}
		    		//处理缓存变更集
		    		if(changeSetKey != null && changeSetKey !== "") {
			    		_this.loadChangeSet(changeSetKey, function() {
			    			_this.trigger("onAfterLoad", []);
				    		_this.trigger("gridComplete",[]);
				    		
				    		if(typeof callBack === "function") {
				    			callBack.apply(_this);
				    		}
				    		hasFirst = true;
				    		//_this.setHeaderLabel("dxmc", "test", 1);
				    		_this._lockDestroy = false;
				    		_this = null;
			    		});
		    		} else {
		    		
			    		_this.trigger("onAfterLoad", []);
			    		_this.trigger("gridComplete",[]);
			    		
			    		if(typeof callBack === "function") {
			    			callBack.apply(_this);
			    		}
			    		hasFirst = true;
			    		//_this.setHeaderLabel("dxmc", "test", 1);
			    		_this._lockDestroy = false;
			    		_this = null;
		    		}
		    		
		    	});	
	    	} catch(e) {
	    		_this.trigger("loadError",[null,e,e.message]);
	    		_this.logInfo("[initValue] error:" + e.message + e.stack);
	    	}
	    	if(!hasFirst) {
				this.topNode = this.dataSet.getCurNode();
				this.selRect.beginRowNode = this.topNode;
				this.selRect.endRowNode = this.topNode;	 
				this.topCount = 0;
			}
	    	if(!hasFirst && this.getOption().isExpanded != false) {
	    		if(this.getOption().defSelect) {
                	this.first();
				} else {
					this.noSelect();
				}	
	    	}
	    	this._suitTitleHeight();
	    },
	    /**
	     * 初始化表格数据.
	     * @param value 数据集
	     */
	    value:function(value, sortState, changeSetKey, callBack) {
            if(this._hasDestroy == true) return;
	    	if(this._lockValue == true) {
    			if(typeof this._icpData == "function") {
    				this._icpData(value);
    			}
    			return;
    		}
	    	if(arguments.length){
	            this.initValue(value, sortState, changeSetKey, callBack);
			} else {
				return this.getDisplayAsJson(true);
			}
	    },
	    getPrintData:function(callBack) {
	    	var re = {};
	    	var grid = this;
	    	this.getRangeData("all", true, function(datas) {
	    		re[grid.getName()] = datas;
	    		var sum = {"rn":grid.summaryText};
	    		var cms = grid.getOption().colModels;
	    		for(var i = 0, len = cms.length; i < len; i++) {
	    			var cm = cms[i];
	    			sum[cm.name] = grid.dataSet.getDisplay(cm.name, grid.dataSet.getSummary(cm.name));
	    		}
	    		re[grid.getName() + "_sum"] = [sum];
	    		if(typeof callBack == "function") {
	    			callBack(re);
	    		}
	    	});    	
	    },
	    /**
	     * 初始化表格数据.
	     * @param value 数据集
	     */
	    addJSONData:function(json) {
	    	this.initValue(json.data);
	    },
	    /**
	     * 选择指定节点.
	     * @param {node} node
	     */
	    select:function(node) {
	    	this.dataSet.select(node);
	    	if(typeof this.onSelect == "function" && this.focusSelect != true) {
	    		try {
	    			//执行选择事件.		    			
	    		    this.onSelect(this.dataSet.curNode, this.getFieldName());
	    		} catch(e) {
	    			this.logInfo("[onSelect]ERR:" + e.message);
	    		}
	    	}
	    	this.trigger("onCellSelect",[this.getPKeyName(), this.colIndex, this]);
	    	this.trigger("onSelectEcpRow",[this.getSelectRowIds(), this.getFieldName()]);
	    },
	    /**
	     * 执行区域选择节点事件.
	     */
	    doSelect:function(ev) {
	    	//alert("click cell");
	        
	    	var opt = this._option;
	    	var _this = opt._this;
	    	var cNode = this.parentNode._node;
	    	if(_this.isTreePointClick === true) {
	    		_this.isTreePointClick = false;
	    		return;
	    	}
	    	_this.mouseEdit = false;
	    	if(_this.isSelect) {
	    		if(_this.trigger("beforeSelectRow",[_this.dataSet.getCurNode(), cNode]) === false) {
	    			return;
	    		}
	    		//_this._selRect = $.extend({}, _this.selRect);
	    		if(_this.dataPost != false) {
			    				    	
			    	//处理行
			    	if(_this.dataSet.getCurNode().recNo != cNode.recNo || _this.shiftKeyDown) {
			    		var ri = _this.dataSet.getIndex();		            
			            var cri = cNode.getIndex();
			            if(_this.shiftKeyDown) {
			            	//按shift键 选择行
			            	if(ri == _this.selRect.beginRowNode.getIndex()) {
				            	if(cri >= _this.selRect.beginRowNode.getIndex()) {
				    	    		_this.selRect.endRowNode = cNode;
				    	    		_this.dataSet.select(_this.selRect.beginRowNode);
				    	    	} else {
				    	    		_this.selRect.endRowNode = _this.selRect.beginRowNode;
				    	    		_this.selRect.beginRowNode = cNode;
				    	    		_this.dataSet.select(_this.selRect.endRowNode);
				    	    	}
			            	} else {
			            		if(cri <= _this.selRect.endRowNode.getIndex()) {
			            			_this.selRect.beginRowNode = cNode;
			            			_this.dataSet.select(_this.selRect.endRowNode);
			            		} else {
			            			_this.selRect.beginRowNode = _this.selRect.endRowNode;
			            			_this.selRect.endRowNode = cNode;
			            			_this.dataSet.select(_this.selRect.beginRowNode);
			            		}
			            	}
			            } else {
			            	_this.post();
			            	_this.dataSet.select(cNode);
				            _this.selRect.beginRowNode = cNode;
				            _this.selRect.endRowNode = _this.selRect.beginRowNode;
			            }		            
			            this.tmpClassName = "";		            
			    	} else {
			    		_this.selRect.beginRowNode = cNode;
			            _this.selRect.endRowNode = _this.selRect.beginRowNode;
			    	}
			    	//处理列
			    	if(this._cellIndex !== _this._colOrder["@INDEX"] || _this.shiftKeyDown) {
			    		var ci = _this.colIndex;
			    	    _this.colIndex = this._cellIndex;
			    	    var cci = _this.colIndex;
			    	    if(_this.shiftKeyDown) {
			    	    	//按shift选择列
			    	    	if(cci == 0) {
			    	    		_this.selRect.beginColIndex = 1;
					    		_this.selRect.endColIndex = _this.colCount - 1;
					    		_this.colIndex = 1;
			    	    	} else if(ci == _this.selRect.beginColIndex) {
				    	    	if(cci >= _this.selRect.beginColIndex) {
				    	    		_this.selRect.endColIndex = cci;
				    	    		_this.colIndex = _this.selRect.beginColIndex;
				    	    	} else {
				    	    		_this.selRect.endColIndex = _this.selRect.beginColIndex;
				    	    		_this.selRect.beginColIndex = cci;
				    	    		_this.colIndex = _this.selRect.endColIndex;
				    	    	}
			    	    	} else {
			    	    		if(cci <= _this.selRect.endColIndex) {
			    	    			_this.selRect.beginColIndex = cci;
			    	    			_this.colIndex = _this.selRect.endColIndex;
			    	    		} else {
			    	    			_this.selRect.beginColIndex = _this.selRect.endColIndex;
			    	    			_this.selRect.endColIndex = cci;
			    	    			_this.colIndex = _this.selRect.beginColIndex;
			    	    		}
			    	    	}
			    	    } else {
			    	    	_this.post();
				    	    _this.selRect.beginColIndex = _this.colIndex;
				    	    _this.selRect.endColIndex = _this.colIndex;
				    	    _this.colIndex = _this.selRect.beginColIndex;
			    	    }		    	    
			    	} else {
			    		_this.post();
			    		_this.selRect.beginColIndex = 1 + _this._colIndexDeff();
			    		_this.selRect.endColIndex = _this.colCount - 1;
			    		_this.colIndex = 1 + _this._colIndexDeff();
			    		var groups = [];
			    	    for(var i = 0, ilen = _this.getOption().colModels.length; i < ilen; i++) {
			    	    	var cm = _this.getOption().colModels[i];
			    	    	if(cm.groups === true) {
			    	    		groups.push(cm.name);
			    	    	}
			    	    }
			    	    _this._refreshMulSelect(groups);
			    	}
			    	_this.logInfo("select cell");
			    	_this.refresh(null, true);
			    	if(_this._lastNode != null && _this.dataSet.getCurNode().recNo == _this._lastNode.recNo) {
			    		_this.scrollBar.scrollNext();
			    	}
			    	if(typeof _this.onSelect == "function" && this.focusSelect != true) {
			    		try {
			    			//执行选择事件.		    			
			    		    _this.onSelect(_this.dataSet.curNode, _this.getFieldName());
			    		} catch(e) {
			    			_this.logInfo("[onSelect]ERR:" + e.message);
			    		}
			    	}
			    	_this.trigger("onCellSelect",[_this.getPKeyName(),_this.colIndex,_this,ev]);
			    	_this.trigger("onSelectEcpRow",[_this.getSelectRowIds(),_this.getFieldName(),ev]);
			    	//单元格单击事件
			    	if(typeof _this.onClick == "function" && this.focusClick != true) {
			    		try {
			    			//执行选择事件.		    			
			    		    _this.onClick(_this.dataSet.curNode, _this.getFieldName());
			    		} catch(e) {
			    			_this.logInfo("[onClick]ERR:" + e.message);
			    		}
			    	}
			    	_this.trigger("onClick",[_this.dataSet.curNode, _this.getFieldName()]);
			    	this.focusClick = false;
			    	this.focusSelect = false;
		    	} else {
		    		if(_this.inputFocus && _this._hasScroll !== true) {
		    			if(typeof _this.editObject.setFocus == "function") {
		    		        _this.editObject.setFocus();
		    			}
		    		}		    		
		    	}		
	    	}
	    	_this.dataPost = true;
	    	_this.isSelect = true;
	    },
	    /**
	     * 执行滚动事件.
	     * @param scrollIndex 滚动序号
	     * @param scrollCount 滚动数量
	     */
	    doScroll:function(scrollIndex, scrollCount) {
	    	if(scrollCount !== 0) {
	    		var _this = this;
	    		_this.post();
		    	_this.topIndex = scrollIndex;
		    	_this.dataSet.beginUpdate();
		    	var tmpNode = _this.dataSet.curNode;
		    	_this.dataSet.select(_this.topNode);
		    	if(scrollCount > 0) {
		    		for(var i = 0; i < scrollCount; i++) {
		    			_this.dataSet.next();
		    		}
		    	} else {
		    		for(var i = 0; i > scrollCount; i--) {
		    			_this.dataSet.prior();
		    		}
		    	}
		    	_this.topNode = _this.dataSet.curNode;
		    	_this.dataSet.select(tmpNode);
		    	tmpNode = null;
		    	_this.dataSet.endUpdate(false);	
		    	if(_this._update) {
		            _this.refresh();
		    	}
		        _this = null;
		    }
	    	if(this.scrollBar.scrollIndex + this.scrollBar.visibleCount === this.scrollBar.scrollCount) {
	            if(typeof this.onScrollEnd == "function") {
	              try {
	                this.onScrollEnd();
	              } catch(e) {
	                this.logInfo("[onScrollEnd]ERR:" + e.message + e.stack);
	              }
	            }
	            this.trigger("onScrollEnd",[]);
	          }
	          if(this.scrollBar.scrollIndex == 0) {
	            if(typeof this.onScrollBegin == "function") {
	              try {
	                this.onScrollBegin();
	              } catch(e) {
	                this.logInfo("[onScrollBegin]ERR:" + e.message + e.stack);
	              }
	            }
	            this.trigger("onScrollBegin",[]);
	          }
	    },
	    /**
	     * 鼠标滚动事件
	     * @param ev 事件对象
	     */
	    doMouseWheel:function(ev) {
	    	this.base(ev);
	        var ent = ev;
	        var scint = 0;
	        if(this.scrollBar.visible && (this.isMouseOver == null || this.isMouseOver() === true)
                    && (this.editObject == null || this.editObject.getPopState() !== true)) {
		        if (ent.wheelDelta) {
		            scint = ent.wheelDelta;
		        } else {
		            scint = ent.detail * (-1);
		        }
		        var re = false;
		        if (scint > 0) {
		        	this.scrollBar.scrollPrior();
		        } else {
		        	this.scrollBar.scrollNext();
		        }
		        ent.returnValue = re;
		        ent = null;
		        scint = null;
		        return re;
	        }
	        return true;
	    },
	    /**
	     * 显示当前格.
	     * @param cell 元素
	     */
	    showFocusCell:function(cell) {
	    	if(cell == null) {
	    	    cell = this.curCell;
	    	}
	    	if(cell != null) {
	    		//当前可见窗口宽度
    			var gridWidth = this.listDiv.offsetWidth;
    			//固定列占用的宽度
    			var gridLeft = this.fzGridTable.offsetWidth;
    			//获取cell的绝对rect
    			var oRect = cell.getBoundingClientRect();
    			//listDiv的绝对left位置
    			var divLeft = this.listDiv.getBoundingClientRect().left;
    			//单元格在listDiv中的left位置
    			var rleft = oRect.left - divLeft;
    			//单元格在listDiv中的right位置
    			var rRight = oRect.right - divLeft;
    			if(this.colIndex == 1 +　this._colIndexDeff() || this.colIndex < this.fzColCount) {
	            	this.listDiv.scrollLeft = 0;
	            } else if(rRight > gridWidth + 2) {
	            	this.listDiv.scrollLeft = cell.offsetLeft + cell.offsetWidth - gridWidth + 2;
	            } else if(rleft < gridLeft) {
	            	this.listDiv.scrollLeft = this.listDiv.scrollLeft - (gridLeft - rleft) - 2; 
	            }
            }
	    },
	    /**
		 * 向右键+TAB键+Enter按键的处理方法
		 * _moveRight方法是内部方法
		 * @name _moveRight
	     * @param {object} ev 事件对象
	     * @param {number} key 键值
		 * @inner 
		 * @ignore		 
		 * @author zengyuangai
		 * @version 1.0
		 * @date 2014-6-30		 
		 */
		_moveRight:function(ev,key) {
			//向右键+TAB键
			this.scrollToFocus();
			var mv = 0
			var cv = this.colIndex - this._colIndexDeff();
			var cm = this.getOption().colModels;
			if(cm[cv] == null) {
				return false;
			}
			var cmLen = cm.length;
			while(cv < cmLen && cm[cv].hidden) {
				mv ++;
				cv ++;
			}
			cm = null;
			var maxIndex = this.colCount - 1;
			if(this.colIndex + mv < maxIndex || ev.shiftKey) {	    			
				if(ev.shiftKey && key == this.keyBoard.RIGHT) {
					if(this.colIndex > this.selRect.beginColIndex) {
						this.selRect.beginColIndex += mv + 1;
					} else if(this.selRect.endColIndex < maxIndex) {
						this.selRect.endColIndex += mv + 1;
					}
					this.refresh(null, true);
				} else {
					this.post();
					if(this.dataPost) {
						this.colIndex += mv + 1;	
						this.selRect.beginColIndex = this.colIndex;
						this.selRect.endColIndex = this.colIndex;
						this.selRect.beginRowNode = this.dataSet.getCurNode();
						this.selRect.endRowNode = this.selRect.beginRowNode;
						this.refresh(null, true);
						this.showFocusCell(this.curCell);						
					} else {
						if(this.inputFocus && this._hasScroll !== true) {
							if(typeof this.editObject.setFocus == "function") {
							    this.editObject.setFocus();
							}
							this.mouseEdit = false;
							//this.dataPost = true;
						}
					}		    	    		
				}		    			    		
			} else if(this.colIndex + mv == maxIndex){
				this.post();
				if(this.dataPost) {
					var recNo = this.dataSet.getRecNo();
					this.next();
					var Eof = this.dataSet.isEof();
					this.refresh();
					if(!Eof){
						this.listDiv.scrollLeft = 0;
						this.colIndex = 1 + this._colIndexDeff();
						this.selRect.beginColIndex = this.colIndex;
						this.selRect.endColIndex = this.colIndex;
						this.selRect.beginRowNode = this.dataSet.getCurNode();
						this.selRect.endRowNode = this.selRect.beginRowNode;
						this.refresh();						
					}					
				} else {
					if(this.inputFocus && this._hasScroll !== true) {
						if(typeof this.editObject.setFocus == "function") {
						    this.editObject.setFocus();
						}
					}
				}
			}
			return false;
		},
		/**
		 * 向左键 Shift+TAB键  Shift+Enter按键的处理
		 * _moveLeft方法是内部方法
		 * @name _moveLeft
	     * @param {object} ev 事件对象
	     * @param {number} key 键值
		 * @inner
		 * @ignore
		 * @author zengyuangai
		 * @version 1.0
		 * @date 2014-6-30		 
		 */
		_moveLeft:function(ev,key) {
			this.scrollToFocus();	
			var mv = 0
			var cv = this.colIndex - mv - 2 - this._colIndexDeff();
			var cm = this.getOption().colModels;
			while(cv >= 0 && cm[cv].hidden) {
				mv ++;
				cv = this.colIndex - mv - 2 - this._colIndexDeff();
			}
			cm = null;
			if(this.colIndex > 1 + mv + this._colIndexDeff() || (ev.shiftKey &&  key == this.keyBoard.LEFT) ) {
				if(ev.shiftKey &&  key == this.keyBoard.LEFT) {
					if(this.colIndex < this.selRect.endColIndex) {
						this.selRect.endColIndex -= mv + 1;
					} else if(this.selRect.beginColIndex > 1) {
						this.selRect.beginColIndex -= mv + 1;		    				
					}
					this.refresh(null, true);
				} else {
					this.post();
					if(this.dataPost) {
						this.colIndex -= mv + 1;
						this.selRect.beginColIndex = this.colIndex;
						this.selRect.endColIndex = this.colIndex;
						this.selRect.beginRowNode = this.dataSet.getCurNode();
						this.selRect.endRowNode = this.selRect.beginRowNode;
						this.refresh(null, true);
						this.showFocusCell(this.curCell);
					} else {
						if(this.inputFocus && this._hasScroll !== true) {
							if(typeof this.editObject.setFocus == "function") {
							    this.editObject.setFocus();
							}
						}
					}		    	    		
				}	
			} else if(this.colIndex + mv == 1 + this._colIndexDeff()){
					this.post();
					if(this.dataPost) {
						var recNo = this.dataSet.getRecNo();
						this.dataSet.prior();
						var bof = this.dataSet.isBof();
						if(this.topNode.recNo == recNo) {
							this.scrollBar.scrollPrior();
						} else {
							this.refresh();
						}
						if(!bof){
							this.listDiv.scrollLeft = this.listDiv.scrollWidth;
							this.colIndex = this.colCount - 1;
							this.selRect.beginColIndex = this.colIndex;
							this.selRect.endColIndex = this.colIndex;
							this.selRect.beginRowNode = this.dataSet.getCurNode();
							this.selRect.endRowNode = this.selRect.beginRowNode;
							this.refresh(null, true);
						}
				} else {
					if(this.inputFocus && this._hasScroll !== true) {
						if(typeof this.editObject.setFocus == "function") {
						    this.editObject.setFocus();
						}
					}
				}
			}
	    	    return false;
		},
	    /**
	     * 键盘按下
	     * @param ev 事件对象
	     * @param key 键值
	     */
	    doKeyDown:function(ev, key) {
	    	if(this.dataSet.getRecordCount() <= 0) return false;
	    	//Home按键 跳转到第一行
			if(this.keyBoard.HOME == key){
				if(this.mouseEdit){
					return true;
				}
				this.first();
				this.refresh();
				return true;
			} else if(this.keyBoard.END == key){
				if(this.mouseEdit){
					return true;
				}
				//End按键 跳转到最后一行
				this.last();
				this.refresh();
				this.scrollBar.scrollNext();
				return true;
			} else if(this.keyBoard.ESC == key){	
				//ESC 按键处理 恢复数据
				if(this.editObject != null) {
					if(this.dataPost) {
						if(typeof this.editObject.refresh == "function") {
					        this.editObject.refresh();
						}
					} else {
						if(typeof this.editObject.setValue == "function") {
						    this.editObject.setValue(this.dataSet.getDisplay(this.getFieldName()));
						}
						this.dataPost = true;
					}
				}
			} else if(ev.shiftKey && this.keyBoard.TAB == key){
				//Shift+tab 按键处理
				this._moveLeft(ev,key);
				return true;
			} else if(ev.ctrlKey || this.priorKey === this.keyBoard.CTRL) {
	    		this.doPaste = false;
	    		if(key == this.keyBoard.C) {
	    			//复制
	    			this.hasCopy = true;
	    			return true;
	    		}
	    		//Ctrl+A 全选
				if(key == this.keyBoard.A){
						this.colIndex = 1;
			    		this.selRect.beginColIndex = 1;
			    		this.selRect.endColIndex = this.colCount - 1;
			    		this.dataSet.beginUpdate();
			    		this.dataSet.last();
			    		this.selRect.endRowNode = this.dataSet.getCurNode();
			    		this.dataSet.first();
			    		this.selRect.beginRowNode = this.dataSet.getCurNode();	    		
			    		this.dataSet.endUpdate(false);
			    		//点表头时直接进入焦点.
			    		if(!this.focus) {
			    			this.setFocus();
			    		}
			    		this.refresh();

				 }		
				return this.priorKey === this.keyBoard.CTRL;
	    	} else if(key == this.keyBoard.DOWN){
	    		if(this.mouseEdit){
					return true;
				}
	    		if(this.dataSet.getLevel() < 0) {
	    			this.first();
	    			this.mouseEdit = false;
	    			return false;
	    		}
	    		//向下键
	    		if(ev.shiftKey) {
	        		var ri = this.dataSet.getIndex();
	        		var tn = this.dataSet.getCurNode();
	        		this.dataSet.beginUpdate();
	        		this.dataSet.next();
	        		if(ri > this.selRect.beginRowNode.getIndex()) {
	        			this.dataSet.select(this.selRect.beginRowNode);
	        			this.dataSet.next();
	        			this.selRect.beginRowNode = this.dataSet.getCurNode();
	        		} else {
	        			this.dataSet.select(this.selRect.endRowNode);
	        			this.dataSet.next();
	        			this.selRect.endRowNode = this.dataSet.getCurNode();
	        		}
	        		this.dataSet.select(tn);
	        		this.dataSet.endUpdate(false);
	        		tn = null;
	        		this.refresh(null, true);
	    		} else {	
	    			this.post();
	    			if(this.dataPost) {
		    			this.dataSet.beginUpdate();
		    			var tn = this.dataSet.getCurNode();
		    			this.dataSet.next();
		    			this.selRect.beginRowNode = this.dataSet.getCurNode();
	    	    		this.selRect.endRowNode = this.selRect.beginRowNode;
	    	    		this.selRect.beginColIndex = this.colIndex;
	    	    		this.selRect.endColIndex = this.colIndex;
	    	    		this.dataSet.select(tn);
	    	    		this.dataSet.endUpdate(false);
	    	    		tn = null;
		    		    this.next();
	    		    } else {
	    		    	if(this.inputFocus && this._hasScroll !== true) {
	    		    		if(typeof this.editObject.setFocus == "function") {
			    		        this.editObject.setFocus();
	    		    		}
			    		}
	    		    }
	    		    
	    		}	    
	    		this.mouseEdit = false;
	    		return false;
	    	} else if(key == this.keyBoard.UP){
	    		if(this.mouseEdit){
					return true;
				}
	    		if(this.dataSet.getLevel() < 0) {
	    			return false;
	    		}
	    		//向上键
	    		if(ev.shiftKey) {
	    			this.dataSet.beginUpdate();
	    			var ri = this.dataSet.getIndex();
	    			var tn = this.dataSet.getCurNode();	        		
	    			if(ri < this.selRect.endRowNode.getIndex()) {
	    				this.dataSet.select(this.selRect.endRowNode);
	    				this.dataSet.prior();
        				this.selRect.endRowNode = this.dataSet.getCurNode();;
        			} else {
        				this.dataSet.select(this.selRect.beginRowNode);
	    				this.dataSet.prior();
        				this.selRect.beginRowNode = this.dataSet.getCurNode();;       				
        			}
	    			this.dataSet.select(tn);
	    			this.dataSet.endUpdate(false);
	        		this.refresh();
	    		} else {
	    			this.post();
	    			if(this.dataPost) {
		    			this.dataSet.beginUpdate();
		    			var tn = this.dataSet.getCurNode();
		    			this.dataSet.prior();	    			
		    			this.selRect.beginRowNode = this.dataSet.getCurNode();
	    	    		this.selRect.endRowNode = this.selRect.beginRowNode;
	    	    		this.selRect.beginColIndex = this.colIndex;
	    	    		this.selRect.endColIndex = this.colIndex;
	    	    		this.dataSet.select(tn);
	    	    		tn = null;
	    	    		this.dataSet.endUpdate(false);
		    			this.prior();	
	    			} else {
	    		    	if(this.inputFocus && this._hasScroll !== true) {
	    		    		if(typeof this.editObject.setFocus == "function") {
			    		        this.editObject.setFocus();
	    		    		}
			    		}
	    		    }
	    		}	    	
	    		this.mouseEdit = false;
	    		return false;
	    	} else if(key == this.keyBoard.RIGHT || key == this.keyBoard.TAB) {
	    		//向右键
	    		if(this.mouseEdit && key == this.keyBoard.RIGHT){
					return true;
				}
	    		if(this.dataSet.getLevel() < 0) {
	    			return false;
	    		}
				if(key == this.keyBoard.TAB){
					this.mouseEdit = false;
				}
				this._moveRight(ev,key);
				return false;
	    	} else if(key == this.keyBoard.LEFT){
	    		if(this.mouseEdit){
					return true;
				}
	    		if(this.dataSet.getLevel() < 0) {
	    			return false;
	    		}
	    		//向左键
				this._moveLeft(ev,key);				
				return false;
	    	} else if(key == this.keyBoard.F2) {
	    		if(this.editObject != null && this.editObject.className !== "ComboBox"
	    			&& this.editObject.className !== "BottonEdit") {
	    		    this.mouseEdit = !this.mouseEdit;
	    		}
	    	} else if(ev.shiftKey) {
	    		this.shiftKeyDown = true;
	    	}			
	    },
	    post:function() {
	    	//
	    },
	    /**
	     * 键盘弹起
	     * @param ev 事件对象
	     * @param key 键值
	     */
	    doKeyUp:function(ev, key) {
	    	if(this.overKey) {
	    		this.overKey = false;
	    		return false;
	    	}
	    	if(ev.ctrlKey || this.hasCopy || this.doPaste) {
		    	if(key == this.keyBoard.C) {
		    		//复制
		    		this.clearMark = null;
		    		this.refresh();
		    		//return false;
		    	} else if (key == this.keyBoard.PgUp){    //向上翻页
					for(var i = 0; i < this.rowCount - 1; i++) {
						this.scrollBar.scrollPrior();
					}
					return true;
				}else if(key == this.keyBoard.PgDn){    //向下翻页
					for(var i = 0; i < this.rowCount - 1; i++) {
						this.scrollBar.scrollNext();
					}
					return true;
				}
		    		    	
	    	} else if(key == this.keyBoard.ENTER){
	    		this.mouseEdit = false;
	    		if(this.dataSet.getLevel() < 0) {
	    			return false;
	    		}
	    		//回车
	    	    this.post();
				if(this.getOption().EnterDown){		    		
		    	    if(this.dataPost) {
		    	    	if(ev.shiftKey){	    	       
				    		var recNo = this.dataSet.getRecNo();
				    		this.dataSet.prior();
							var bof = this.dataSet.isBof();
							if(this.topNode.recNo == recNo) {
								this.scrollBar.scrollPrior();
							} else {
								this.refresh();
							}
							if(bof && this.colIndex > 1){
								this.colIndex = this.colIndex - 1;
								this.last();						
								this.selRect.beginColIndex = this.colIndex;
								this.selRect.endColIndex = this.selRect.beginColIndex;
								this.selRect.beginRowNode = this.dataSet.getCurNode();
								this.selRect.endRowNode = this.selRect.beginRowNode;
								this.scrollBar.scrollNext();
							}
						} else {
							var recNo = this.dataSet.getRecNo();
				    		this.dataSet.next();
				    		this.selRect.beginRowNode = this.dataSet.getCurNode();
							this.selRect.endRowNode = this.selRect.beginRowNode;
				    		var eof = this.dataSet.isEof();
				    		if(!eof && this.bottomNode.recNo == recNo) {
				    		    this.scrollBar.scrollNext();
				    		} else {
				    		    this.refresh();
				    		}
				    		if(eof && this.colIndex < this.colCount - 1){
								this.colIndex = this.colIndex + 1;
								this.first();	//this.last();						
								this.selRect.beginColIndex = this.colIndex;
								this.selRect.endColIndex = this.selRect.beginColIndex;
							}				    		
						}
		    		} else {
	    		    	if(this.inputFocus && this._hasScroll !== true) {
	    		    		if(typeof this.editObject.setFocus == "function") {
			    		        this.editObject.setFocus();
	    		    		}
			    		}
	    		    }
		    		return false;	
				}else{
					if(ev.shiftKey){
						this._moveLeft(ev,key);
					}else{
						this._moveRight(ev,key);
					}
					this.setFocus();
				}
	    	} else if(!ev.shiftKey) {
	    		this.shiftKeyDown = false;
	    	}	    
	    	this.pasteKeyPress = false;
	    	this.priorKey = key;
	    },
	    /**
	     * 添加树节点.
	     * @param rowId 行ID
	     * @param data 数据行
	     * @param nodeFlag 添加类型 brother、child
	     */
	    addTreeNode:function(rowId, data, nodeFlag) {
	    	if((this.isEmpty(data) || typeof data == "string") && typeof rowId == "object") {
	    		nodeFlag = data;
	    		data = rowId;
	    		rowId = null;
	    	}
	    	if(this.isEmpty(data)) {
	    		return false;
	    	}
	    	var len = 1;
	    	if(this.isArray(data)) {
	    		len = data.length;
	    	}
	    	this._addNew = true;
	    	var me = this;
	    	var nodeFlag = nodeFlag || "brother";
	    	if(nodeFlag === "brother") {
	    		this.dataSet.append(data, undefined, function() {
	    			if(len > 50) {
	    				me.refresh();
	    			}
	    		});
	    	} else if(nodeFlag === "child") {
	    		this.dataSet.appendChild(data, undefined, function() {
	    			if(len > 50) {
	    				me.refresh();
	    			}
	    		});
	    	}
	    	this.trigger("afterInsertRow",[this.getPKeyName(),data,nodeFlag]);
	    	if(len <= 50) {
	    	    this.refresh();
	    	}
	    },
	    /**
	     * 删除树节点.
	     * @param rowId 行ID
	     */
	    delTreeNode:function(rowIds) {
	        this.delEcpRowData(rowIds);
	    },
	    
	    delRecord:function(rowIds) {
	    	this.delEcpRowData(rowIds);
	    },
	    /**
	     * 删除树节点.
	     * @param rowId 行ID
	     * @param isCurren 是否当前行 
	     */
	    delEcpRowData:function(rowIds) {
	    	if(this.dataSet.getRecordCount() > 0) {
		    	//如删除点为刷新的顶点.
		    	var cn = this.dataSet.getCurNode();
		    	var isFirst = cn != null && this.topNode.recNo === cn.recNo;
		    	var delCount = 0;
		    	var isEnd = this.selRect.endRowNode.recNo == cn.recNo;
		    	var isBegin = this.selRect.beginRowNode.recNo == cn.recNo;
		    	if(rowIds != null) {
		    		var kn = this.getPKeyName();
		    		if(this.isArray(kn)) {
		    			if(kn.length > 0) {
		    				kn = kn[0];		    				
		    			} else {
		    				return;
		    			}
		    		}
		    		if(this.isArray(rowIds)) {
		    			var isF = false;
		    			for(var i = 0, len = rowIds.length; i < len; i++) {
		    				var rowid = rowIds[i];
		    				if(this.dataSet.getValue(kn) == rowid 
			    					|| this.dataSet.locate(kn, rowid, true)) {
			    				if(this.dataSet.getValue(kn, cn) == this.dataSet.getValue(kn)) {
			    					isF = true;
			    				}
			    				this.dataSet.delRecord();
			    				delCount++;
			    			}
		    			}
		    			isFirst = isF;
		    		} else {
		    			if(this.dataSet.getValue(kn) == rowIds 
		    					|| this.dataSet.locate(kn, rowIds, true)) {
		    				if(this.dataSet.getValue(kn, cn) != this.dataSet.getValue(kn)) {
		    					isFirst = false;
		    				}
		    				this.dataSet.delRecord();
		    				delCount++;
		    			}		    			
		    		}
		    	} else {
		    	    this.dataSet.delRecord();
		    	    delCount++;
		    	}
		    	//删除后，自动移到另一条明细，因此执行事件
		    	if(this.dataSet.getRecordCount() > 0) {
		    		if(this.hasbind("rowChanged")) {
		    			this.trigger("rowChanged", [this.dataSet]);
		    		}
			    	if(typeof this.onRowChanged == "function") {
		    			try {
		    			    this.onRowChanged(this.dataSet);
		    			} catch(e) {
		    				this.logInfo("onRowChanged event fire error!");
		    			}
		    		}
			    	this.trigger("onRowChanged", [this.dataSet]);
		    	}
		    	cn = this.dataSet.getCurNode();
		    	//多选择的时候，删除会有问题， 但是，删除后，区域选择的状态，还需要处理.????
		    	//this.selRect.beginRowNode = this.dataSet.getCurNode();
		    	//this.selRect.endRowNode = this.selRect.beginRowNode;	    	
		    	if(isEnd) {
		    		this.selRect.endRowNode = cn;
		    	}
		    	if(isBegin) {
		    		this.selRect.beginRowNode = cn;
		    	}
		    	if(isFirst && this.dataSet.getRecordCount() > 0) {
		    	    this.topNode =  this.dataSet.getCurNode();
		    	    if(this.topNode.scrIndex > 1) {
		    	        this.topNode.scrIndex--;
		    	    }
		    	}
		    	if(delCount > 0) {
		    		if(this.getOption().pager === true) {
		    			var oldc = this.pageObj.getTotalCount();
		    			this.pageObj.setTotalCount(oldc-delCount, false);
		    		}
		    	}
		    	cn = null;
		    	this.refresh();
		    	
	    	}
	    	if(this.multiSelect === true && this.dataSet.getRecordCount() == 0) {
	    		this.setTitleChecked("@MUL", false);
	    	}
	    },
	    /**
	     * 返回当前滚动的行.
	     */
	    getScrollIndex:function() {
	    	if(this.topNode != null) {
	    		return this.topNode.scrIndex;
	    	} else {
	    		return 1;
	    	}
	    },
	    /**
	     * 滚动到第几列.
	     * @param index 顶序号
	     */
	    scrollToIndex:function(index) {
	    	if(index > 1) {
	    		if(index > this.dataSet.getRecordCount()) {
	    			index = this.dataSet.getRecordCount();
	    		}
	    		var re = true;
	    		if(index > 1) {
		    		this.dataSet.beginUpdate();
		    		var cn = this.dataSet.getCurNode();
		    		var dcount = 0
		    		this.dataSet.select(this.topNode);
		    		if(index > this.topNode.scrIndex) {
			    		while(!this.dataSet.isEof()) {
			    			if(index == this.dataSet.getIndex()) {
			    				break;
			    			} else if(index < this.dataSet.getIndex()) {
			    				re = false;
			    				break;
			    			}
			    			dcount ++;
			    			this.dataSet.next();
			    		}
		    		} else {		    			
		    			while(!this.dataSet.isBof()) {
			    			if(index == this.dataSet.getIndex()) {
			    				break;
			    			} else if(index > this.dataSet.getIndex()) {
			    				re = false;
			    				break;
			    			}
			    			dcount --;
			    			this.dataSet.prior();
			    		}
		    		}
		    		this.dataSet.select(cn);
		    		this.dataSet.endUpdate(false);
		    		if(re === true) {
		    		    this.scrollBar.setScrollIndex(this.scrollBar.scrollIndex + dcount);
		    		}
		    		this.refresh();
	    		} else {
	    			this.first();
	    		}
	    	} else {
	    		this.first();
	    	}
	    },
	    /**
	     * 滚动到焦点行.
	     * @return 返回
	     */
	    scrollToFocus:function() {
	    	if(!this.selRowInShow && this.getRecordCount() > 0) {	    			    		
	    		var cNode = this.dataSet.getCurNode();
	    		var prior = cNode.scrIndex < this.topNode.scrIndex?true:false;
	    		this.dataSet.beginUpdate();
	    		this.dataSet.select(this.topNode);
	    		var bcount = 0;
	    		//循环查找当前行.
	    		while(!this.dataSet.isEof() && !this.dataSet.isBof() 
	    				&& this.dataSet.getRecNo() !== cNode.recNo) {
	    			if(prior) {
	    				this.dataSet.prior();
	    				bcount --;
	    			} else {
	    				this.dataSet.next();
	    				bcount ++
	    			}
	    		}
	    		if(!prior) {
	    			bcount -= this.rowCount - 2;
	    		}
	    		this.dataSet.endUpdate(false);
	    		this.scrollBar.setScrollIndex(this.scrollBar.scrollIndex + bcount);
	    		return true;
	    	}
	    	return false;
	    },
	    /**
	     * 读取数据.
	     * @param fieldName 字段
	     * @return 返回
	     */
	    getValue:function(fieldName, node) {
	    	if(this.dataSet.getRecordCount() > 0) {
	    	    return this.dataSet.getValue(fieldName, node);
	    	}
	    	return null;
	    },
	    /**
	     * 设置数据.
	     * @param fieldName 字段
	     */
	    setValue:function(fieldName, value, node, notCac) {
	    	if(this.dataSet.getRecordCount() > 0) {
	    	    this.dataSet.setValue(fieldName, value, node, notCac);
	    	}
	    },
	    /**
	     * 设置名称转换列表.
	     * @param fieldName 字段
	     * @param idNameJson 转换列表
	     */
	    setTransIDName:function(fieldName, idNameJson) {
	    	this.dataSet.setTransIDName(fieldName, idNameJson);
	    },
	    /**
	     * 获取名称转换列表.
	     * @param fieldName 字段
	     * @return 返回
	     */
	    getTransIDName:function(fieldName) {
	    	return this.dataSet.getTransIDName(fieldName);
	    },
	    /**
	     * 添加名称转换列表.
	     * @param fieldName 字段
	     * @param idNameJson 转换列表
	     */
	    addTransIDName:function(fieldName, idNameJson, idKey, capKey) {	    	
	    	this.dataSet.addTransIDName(fieldName, idNameJson, idKey, capKey);
	    },
	    /**
	     * 获取选择行数据.
	     * @return 返回
	     */
	    getSelectedRowData:function(curOnly){
	    	if(this.dataSet.getRecordCount() > 0) {
	    		if(this.multiSelect && curOnly !== true) {
	    			return this.dataSet.getSelectedData();
	    		} else {
	    			var cn = this.dataSet.getCurNode();
	    			if(cn.level >= 0) {
	    	            return this.dataSet.getCurNode().data;
	    			} else {
	    				return null;
	    			}
	    		}
	    	}
	    	return null;
	    },
	    /**
	     * 下一行.
	     */
	    next:function() {
	    	this.scrollToFocus();
	    	this.post();
    		var recNo = this.dataSet.getRecNo();
    		this.dataSet.next();
    		//重新指定选择的区域
    		this.selRect.beginRowNode = this.dataSet.getCurNode();
    		this.selRect.endRowNode = this.selRect.beginRowNode;
    		if(this.bottomNode != null && this.bottomNode.recNo == recNo) {
    		    this.scrollBar.scrollNext();
    		} else {
    		    this.refresh(null, true);
    		}
	    },
	    /**
	     * 上一行.
	     */
	    prior:function() {
	    	this.scrollToFocus();
	    	this.post();
    		var recNo = this.dataSet.getRecNo();
    		this.dataSet.prior(); 
    		//重新指定选择的区域
    		this.selRect.beginRowNode = this.dataSet.getCurNode();
    		this.selRect.endRowNode = this.selRect.beginRowNode;
    		if(this.topNode.recNo == recNo) {
    		    this.scrollBar.scrollPrior();
    		} else {
    		    this.refresh(null, true);
    		}
	    },
	    /**
	     * 设置高度.
	     * @param value 值
	     */
	    setHeight:function(value, dos) {
	    	this._fzSumTableTop = null;
	    	this.base(value, dos);
	    	if(this.rendered && this._update && dos !== false) {
		    	this.initGrid();
		    	this.refresh();
	    	}	    	
	    },
	    /**
	     * 设置宽度.
	     * @param value 值
	     */
	    setWidth:function(value, dos) {
	    	this.base(value, dos);
	    	if(this.rendered && this._update && dos !== false) {
	            this.refresh();
	        }	        
	    },
	    /**
	     * 跳到第一行.
	     */
	    first:function() {
	    	this.dataSet.first();
	    	this.topNode = this.dataSet.getCurNode();
	    	this.selRect.beginRowNode = this.topNode;
	    	this.selRect.endRowNode = this.topNode;
	    	if(this.topNode.level >= 0) {
	    	    this.topNode.scrIndex = 1;
	    	}
	    	this.beginUpdate();
	    	this.scrollBar.setScrollIndex(0);
	    	this.endUpdate(false);
	    	this.refresh();
	    	//this.scrollToFocus();
	    },
	    /**
	     * 跳到最后一行.
	     */
	    last:function(){
	    	this.dataSet.last();
	    	this.selRect.beginRowNode = this.dataSet.getCurNode();
	    	this.selRect.endRowNode = this.selRect.beginRowNode;
	    	this.refresh();
	    	this.scrollToFocus();
	    },
	    /**
	     * 不选择任何一行
	     */
	    noSelect:function() {
	    	this.dataSet.select(this.dataSet.rootNode);
	    	this.selRect.beginRowNode = this.dataSet.getCurNode();
	    	this.selRect.endRowNode = this.selRect.beginRowNode;
	    	this.refresh();
	    },
	    /**
	     * 获取ecpUI.
	     * @return 返回
	     */
	    getEditCellEcpUI:function() {
	    	return false;
	    },
	    /**
	     * 获取当前行ID.
	     * @return 返回id
	     */
	    getSelectRowIds:function(curOnly) {
	    	var ids = [];
	    	if(this.multiSelect && curOnly !== true) {
	    		ids = this.dataSet.getSelectRowIds();
                return  ids.join(",");
	    	} else {
                if(this.dataSet.getRecordCount() > 0) {
	    		    return this.dataSet.getValue(this.getPKeyName());
                } else {
                    return null;
                }	    		
	    	}
	    },
	    /**
	     * 返回选择的节点id数组.
	     */
	    getSelRowsAsArray:function() {
	    	var ids = [];
	    	if(this.multiSelect && curOnly !== true) {
	    		ids = this.dataSet.getSelectRowIds();
	    	} else {
                if(this.dataSet.getRecordCount() > 0) {
	    		    ids = [this.dataSet.getValue(this.getPKeyName())];
                }    		
	    	}
	    	return ids;
	    },
	    /**
	     * 获得主键对应的值.
	     */
	    getPKeyValue:function(node) {
	    	if(node == null) {
	    		node = this.getCurNode();
	    	}
	    	var pk = this.getOption().primaryKey;
	    	if(this.isEmpty(pk) || this.isArray(pk) && pk.length == 0) {
	    		return "";
	    	} else {
	    		var re = null;
	    		if(typeof pk == "string") {
	    			re = this.dataSet.getValue(pk, node);
	    		} else if(this.isArray(pk)) {
	    			re = [];
	    			for(var i = 0, ilen = pk.length; i < ilen; i++) {
	    				var fn = pk[i];
	    				re.push(this.dataSet.getValue(fn, node));
	    			}
	    		}
	    		return re;
	    	}
	    },
	    /**
	     * 获取关键字段.
	     * @return 返回字段
	     */
	    getPKeyName:function() {
	    	if(this.isEmpty(this.getOption().primaryKey)) {
	    		this.getOption().primaryKey = "gid";
	    	} else if(this.isArray(this.getOption().primaryKey)) {
	    		if(this.getOption().primaryKey.length > 0) {
	    			return this.getOption().primaryKey[0];	    			
	    		} else {
	    			this.getOption().primaryKey = "gid";
	    			return "gid";
	    		}
	    	} else {
	    		return this.getOption().primaryKey;	    		
	    	}
	    },
	    /**
	     * 添加数据行.
	     * @name addEcpRowData
	     * @param dataArr 数组
	     */
	    addEcpRowData:function(dataArr, index) {
	    	var pNode = undefined;
	        if(this.treeGrid == false) {
	        	//非树结构的情况下直接增加在根节点中
	            pNode = this.dataSet.rootNode;
	        }
	        var acount = 0;
	        this._addNew = true;
	        if(index != null && !isNaN(index)) {
	        	var selTop = this.topNode.recNo == this.dataSet.getRecNo();
	        	this.dataSet.insertItemList(index, dataArr, pNode);
	        	if(selTop === true && pNode.cNode[index] != null) {
	        		this.topNode = pNode.cNode[index];
	        		this.dataSet.curNode = this.topNode;
	        	}
	        	if(this.isArray(dataArr)) {
	        	    acount += dataArr.length;
	        	} else {
	        		acount++;
	        	}
	        } else {
	            this.dataSet.appendItemList(dataArr, pNode);
	            if(this.isArray(dataArr)) {
	        	    acount += dataArr.length;
	        	} else {
	        		acount++;
	        	}
	        }
	        if(this.getOption().pager === true) {
	        	var oldc = this.pageObj.getTotalCount();
    			this.pageObj.setTotalCount(oldc+acount, false, this.dataSet.getRecordCount());
	        }
	        if(this.hasbind("onScrollEnd") !== true) {
	    	    this.last();
	        } else {
	        	this.refresh();
	        }
	    },
	    /**
	    * 插入合并列的中间值.
	    */
	    _insertGroupValue:function() {
		    //插入中间值
		    var groups = [];
		    //获取所有配置了合并单元格的列
		    for(var i = 0, ilen = this.getOption().colModels.length; i < ilen; i++) {
			    var cm = this.getOption().colModels[i];
			    if(cm.groups===true){
			    	groups.push(cm.name);
			    }
			}
		    //如果有合并单元格
			if(groups.length > 0) {
			    this.dataSet.beginUpdate();			    
			    var cn = this.dataSet.getCurNode();
			    //选择上一条
			    var pn = null;
			    this.dataSet.prior();	    
			    if(!this.dataSet.isBof()) {
				    pn = this.dataSet.getCurNode();
				    if(pn.level != cn.level) {
				    	pn = null;
				    }
			    }
			    //还原当前行为选择行
			    this.dataSet.select(cn);
			    //选择下一条
			    var nn = null;
			    this.dataSet.next();
			    if(!this.dataSet.isEof()) {
				    nn = this.dataSet.getCurNode();
				    if(nn.level != cn.level) {
				    	nn = null;
				    }
			    }
			    //还原当前行为选择行
			    this.dataSet.select(cn);
			    //前后节点 都不为空
			    if(pn != null && nn != null) {
			    	//循环分组例
				    for(var i = 0, ilen = groups.length; i < ilen; i++) {
					    var fieldName = groups[i];
					    //判断前后节点内容是否一致，
					    var pv = this.getValue(fieldName, pn);
					    if(pv != null && pv !== "" && pv === this.getValue(fieldName, nn)) {
					    	//内容一致，则同步更新值
					    	this.dataSet.setValue(fieldName, pv);
					    }
				    }
			    }
			    this.dataSet.endUpdate(false);
		    }
	    },
	    /**
	    * 插入明细.
	    * @param index 序号
	    * @param item 节点对象
	    */
	    insert:function(index, item) {
	    	if(item == null && index != null && typeof index == "object") {
	    		item = index;
	    		index = null;
	    	}
	    	var recNo = -1;
	    	var cNode = this.dataSet.getCurNode();
	    	if(index != null) {
	    		cNode = this.getChildNode(index, this.dataSet.getParentNode());		    	
	    	}
	    	if(cNode != null) {
	    		recNo = cNode.recNo;
	    	}
	    	var selTop = this.topNode.recNo == recNo;
	    	if(item != null && this.isArray(item)) {
	    		if(index == null) {
	    			index = this.dataSet.getCurNode().index;
	    		}
	    		if(item.length == 1) {
	    			this.dataSet.insertItem(index, item[0]);
		    		if(this.getOption().autoGroups === true) {
		    		    this._insertGroupValue();
		    		}
		    		if(selTop === true) {
		    			this.topNode = this.dataSet.getCurNode();
		    		}
		    		if(this.topNode == null) {
			    		this.first()
			    	} else {
			    	    this.refresh();
			    	}
		        	this.scrollToFocus();
		        	if(this.getOption().pager === true) {
			        	var oldc = this.pageObj.getTotalCount();
		    			this.pageObj.setTotalCount(oldc+1, false, this.dataSet.getRecordCount());
			        }
	    		} else {
		    		this.addEcpRowData(item, index);
		    		if(selTop === true) {
		    			this.topNode = this.dataSet.getCurNode();
		    		}
	    		}
	    	} else {	    		
	    		this.dataSet.insertItem(index, item);
	    		if(this.getOption().autoGroups === true) {
	    		    this._insertGroupValue();
	    		}
	    		if(selTop === true) {
	    			this.topNode = this.dataSet.getCurNode();
	    		}
	    		if(this.topNode == null) {
		    		this.first()
		    	} else {
		    	    this.refresh();
		    	}
	        	this.scrollToFocus();
	        	if(this.getOption().pager === true) {
		        	var oldc = this.pageObj.getTotalCount();
	    			this.pageObj.setTotalCount(oldc+1, false, this.dataSet.getRecordCount());
		        }
	    	}
	    },
	    /**
	     * 添加同级明细.
	     */
	    append:function(item) {
	        if(item != null && this.isArray(item)) {
	        	this.addEcpRowData(item);
	        } else {
	        	this.dataSet.appendItem(item);
	        	if(this.topNode == null) {
		    		this.first()
		    	} else {
		    	    this.refresh();
		    	}
	        	this.scrollToFocus();
	        	if(this.getOption().pager === true) {
		        	var oldc = this.pageObj.getTotalCount();
	    			this.pageObj.setTotalCount(oldc+1, false, this.dataSet.getRecordCount());
		        }
	        }
        },
        /**
         * 增加子明细.
         */
        appendChild:function(item,  pNode) {
        	if(item != null && this.isArray(item)) {
	        	this.addEcpRowData(item);
	        } else {
		        this.dataSet.appendChildItem(item,  pNode);
		        if(this.topNode == null) {
		    		this.first()
		    	} else {
		    	    this.refresh();
		    	}
		        this.scrollToFocus();
		        if(this.getOption().pager === true) {
		        	var oldc = this.pageObj.getTotalCount();
	    			this.pageObj.setTotalCount(oldc+1, false, this.dataSet.getRecordCount());
		        }
	        }
        },
	    /**
	     * 获取表格属性.
	     * @return 返回属性
	     */
	    getGridParam:function() {
	    	if(this.option.colModels == null) {
	    		this.option.colModels = [];
	    	}
	    	return this.option;
	    },
	    /**
	     * 设置表只读.
	     * @param readOnly 只读状态
	     */
	    setReadOnly:function(readOnly) {
	    	var readOnly = readOnly === true;
	    	this.getOption().cellEdit = !readOnly;
	    	this.refresh();
	    },
	    /**
	     * 设置行只读.
	     * @param readOnly 只读状态
	     * @param node 节点
	     */
	    setRowReadOnly:function(readOnly, node) {
	    	var readOnly = readOnly||true;
	    	this.dataSet.setReadOnly(readOnly, node);
	    },	    
	    setColReadOnly:function(fieldName, readOnly) {
	    	this.getColModel(fieldName).editable = readOnly !== true;
	    	this.refresh();
	    },
	    isColReadOnly:function(fieldName) {
	    	return this.getColModel(fieldName).editable === false;
	    },
	    isReadOnly:function() {
	    	return this.getReadOnly();
	    },
	    /**
	     * 获取表格只读属性.
	     * @return 返回只读属性
	     */
	    getReadOnly:function() {
	    	var gridReadOnly = false;//this.getOption().cellEdit;
    		if(this.isEmpty(gridReadOnly)) {
    			gridReadOnly = true;
    		} else if(typeof gridReadOnly == "string") {
    			gridReadOnly = this.getBooleanValue(gridReadOnly, true);
    		}
    		gridReadOnly = !gridReadOnly;
    		return gridReadOnly;
	    },
		/**
	     * 设置行只读.
	     * @param readOnly 只读状态
	     * @param node 节点
	     */
	    isRowReadOnly:function(node) {
	    	return this.dataSet.getReadOnly(node);
	    },
	    
	    isCellReadOnly:function(fieldName, node) {
	    	return this.getCellReadOnly(fieldName, node);
	    },
	    /**
	     * 获取单元格只读属性.
	     */
	    getCellReadOnly:function(fieldName, node) {
	        return true;
	    },
	    /**
	     * 兼容jqGrid表格方法.
	     */
	    _yuiGridFit:function(value) {
	   	    //this.option.ecpTab = value;
	    },
	    /**
	     * 兼容jqGrid表格方法.
	     */
	    _getGridParent:function(isTab) {
	    	//return this.thisWindow.parentElement;
	    	var gridDiv = $(this.thisWindow.parentElement);
	    	pDiv = {};
	    	if (isTab){
		    	pDiv = gridDiv.parents(".tabs-panels:first");
		    	//tabs新页签取不到tabs-panels则取父节点
		    	if (pDiv.length === 0) {
		    		pDiv = gridDiv.parent();
		    	}
	    	} else {
	    		pDiv = gridDiv;
	    	}
	    	return pDiv; 
	    },
	    /**
	     * 兼容jqGrid表格方法.
	     */
	    setVisible:function(fieldName, value) {
	    	//this._getColModel(2).hidden = !this._getColModel(2).hidden;
	    },
	    /**
	     * 改变是否树表.
	     */
	    setTreeGrid:function(types, idkey, pidkey) {
	    	if(this.option == null) {
	    		this.option = {};
	    	}
	    	if(types === false) {
	    		this.getOption().treeGrid = false;
	    	} else {
	    		this.getOption().treeGrid = true;
	    		if(idkey != null && idkey !== "") {
	    			this.getOption().idkey = idkey;
	    		}
	    		if(pidkey != null && pidkey !== "") {
	    			this.getOption().pidkey = pidkey;
	    		}
	    	}
	    	if(this.option.colModels != null) {
		    	for(var i = 0, len = this.option.colModels.length; i < len; i++) {
		        	var cm = this.option.colModels[i];
		        	cm.width = cm._defWidth || cm.width;
		        }
	    	}	    	
	    	this._createTitle(false);
	        this.initGrid();
	    },
	    /**
	     * 执行大小变更.
	     */
	    _doResize:function(el) {
	    	this._gridTableHeight = null;
	    	this._sumTableHeight = null;
	    	if(this._update) {
	    	    this._comRect = this.thisWindow.getBoundingClientRect();
	    	} else {
	    		this._asynRun(function(){
	    			this._comRect = this.thisWindow.getBoundingClientRect();
	    		}, 10);
	    	}	    	
	    	if(this.rendered && this._update) {
	    		this.initGrid();	    		
	    	}
	    	this.base(el);
	    	if(this.rendered && this.getOption().shrinkToFit !== false) {
	    		this.shrinkToFit();    		
	        }
	    	if(this.rendered && this.getOption().suitToFit === true) {
	    		this.suitToFit();    		
	        }
	    	this._suitTitleHeight();	    	
	        if(this.emptyDiv != null) {
		    	this.emptyDiv.style.left = parseInt((this.getWidth()-100)/2, 10) + "px";
		        this.emptyDiv.style.top = parseInt((this.getHeight()-20)/2, 10) + "px";
	    	}
	    },
	    /**
	     * 表头自适应.
	     */
	    setTitleFit:function(fieldNames, col, callBack) {
	    	var cm = null;
	    	if(typeof fieldNames === "string") {
	    		fieldNames = [fieldNames];
	    	}	 
	    	var cols = {}, minWidth = {};
	    	if(col == null) {	    		
		    	for(var i = 0, rlen = this.option.colModels.length; i < rlen; i++) {
		    		cm = this.option.colModels[i];
		    		for(var j = 0, clen = fieldNames.length; j < clen; j++) {
			    		if(cm.hidden != true && cm.name == fieldNames[j]) {
			    			cols[cm.name] = this.titleCol[i];
			    			minWidth[cm.name] = this._getNumberValue(cm.minWidth, 0);
			    		}
		    		}
		    	}
	    	} else if(!(this.isArray(col))) {
	    		cols[fieldNames[0]] = col;
	    		minWidth[fieldNames[0]] = this.getColModel(fieldNames[0]).minWidth;
	    	}
	    	var _grid = this;
	    	if(fieldNames.length > 0) {
	    		var listWidth = _grid._getNumberValue(_grid.listDiv.style.width);
	    		var gridWidth = _grid._getNumberValue(_grid.gridTable.style.width);
    			for(var j = 0, clen = fieldNames.length; j < clen; j++) {
    				 var fn = fieldNames[j];
	    			 var curCol = cols[fn];
	    			 if(curCol == null) continue;
	    			 var cp = $(curCol).text();
	    			 if(cp === "" && curCol.checkBox != null) {
	    				 cp += ".";
	    			 }		    			 
	    			 var nw = _grid.getTextWidth(cp, "14px", "bold") + 8;
	    			 
	    			 if(minWidth[fn] != null && nw < minWidth[fn]) {
	    				 nw = minWidth[fn];
	    			 }
	    			 
	    			 var oldWidth = curCol.offsetWidth;		    			 
	    			 if(oldWidth > 0) {
	    				 if(_grid.getOption().shrinkToFit && _grid._oldGridWidth != null 
	    						 && _grid._oldGridWidth < _grid._width 
	    						 && gridWidth < listWidth && oldWidth > nw) {
	    					 continue;
	    				 }
	    			     _grid._setColWidth(curCol, nw - oldWidth, [oldWidth], 
	    			    		 _grid._getNumberValue(_grid.gridTable.style.width, 1));
	    			 }
    			 } // for
    			 _grid._suitTitleHeight();	  
    			 _grid._oldGridWidth = null;
    			 _grid._tmpWidth = null;
	    	}
	    	if(typeof callBack === "function") {
		        callBack.apply(_grid);
	        }	    	
	    },
	    doShow:function(){
	    	this.base();
	    	//刷新一下
	    	this.refresh();
	    	var _this = this;
	    	this.setContentFit(function() {
	    		if(_this.getOption().shrinkToFit !== false) {
	    		    _this.shrinkToFit();
	    		}
	    		if(_this.getOption().suitToFit === true) {
	    		    _this.suitToFit();
	    		}
	    	});
	    },
	    initMaxText:function() {
	    	this.maxText = {};
		    this.maxTextLen = {};
		    this.maxCapWidth = {};
		    this.maxLevel = 0;
	    },
	    getMaxText:function(fieldNames, callBack, cach) {
	    	if(typeof fieldNames == "string") {
	    		fieldNames = [fieldNames];
	    	}
	    	if(this.isArray(fieldNames) && fieldNames.length > 0) {
	    		if(cach === true) {
	    			var re = true;
	    			for(var j = 0, fdlen = fieldNames.length; re && j < fdlen; j++) {
	    				if(this.maxText == null || this.maxText[fieldNames[j]] == null) {
	    					re = false;
	    				}
	    			}
	    			if(re == true) {
	    				if(typeof callBack == "function") {
		    				callBack(fieldNames, this.maxText);
		    			} 
	    				return;
	    			}
	    		}
	    		if(this.isEmpty(this.maxText)) {
	    		    this.initMaxText();
	    		}
	    		var cacFns = [];
	    		for(var j = 0, fdlen = fieldNames.length; j < fdlen; j++) {
	    			var fn = fieldNames[j];
	    			if(this.maxText[fn] == null) {
		    			this.maxText[fn] = "";
		    			this.maxTextLen[fn] = 0;
		    			cacFns.push(fn);
	    			}
	    		}
	    		var _this = this;
	    		var formatCach = {};
	    		if(this.dataSet.getRecordCount() > 0) {
	    			var dataSet = this.dataSet;
		    		dataSet.savemark();
		    		dataSet.select(this.topNode);		    		
		    		var cct = 0;
		    		var rowLen = this.sheets.length;
		    		var fdlen = fieldNames.length;
		    		while(!dataSet.isEof() && cct < rowLen) {		    			
		    			for(var j = 0; j < fdlen; j++) {
		    				var fn = fieldNames[j];
		    				var curText = dataSet.getDisplay(fn);
		    				var curValue = dataSet.getValue(fn);
		    				if(_this.hasbind("onFormat_" + fn)) {
		    					if(formatCach[curValue] == null) {
		    					    curText = _this.trigger("onFormat_"+fn, [dataSet, fn, curText, curValue]);
		    					    formatCach[curValue] = curText;
		    					} else {
		    						curText = formatCach[curValue] 
		    					}
		    				}
		    				if(typeof curText === "string" && curText.indexOf("<") != -1) {
							    curText = curText.replace(/<(\/)?(a|span|div|li|ul|table|tr|td|input|font)( [^<>]+)?>/gi,"");
							}
		    				var curLen = _this.strLen(curText);
		    				if(curLen > _this.maxTextLen[fn]) {
		    					_this.maxTextLen[fn] = curLen;
		    					_this.maxText[fn] = curText;
		    				}
		    			}
		    			if(dataSet.getLevel() > _this.maxLevel) {
		    				_this.maxLevel = dataSet.getLevel();
		    			}		    			
		    			cct++;
		    			this.dataSet.next();
		    		}
		    		this.dataSet.loadmark();
	    		}
    			if(typeof callBack == "function") {
    				callBack(fieldNames, _this.maxText);
    			}  		
    			formatCach = null;
	    	}//isArray
	    },
	    /**
	     * 设置内容宽度适应.
	     */
	    setContentFit:function(fieldNames, col, callBack) {
	    	if(typeof fieldNames == "function") {
	    		callBack = fieldNames;
	    		fieldNames = null;
	    		col = null;
	    	} else if(typeof col == "function") {
	    		callBack = col;
	    		col = null;
	    	}
	    	//全部自适应.
	    	var isall = (fieldNames == null || fieldNames === "");
    		if(isall) {
    			fieldNames = [];
    		}
	    	if(typeof fieldNames === "string") {
	    		fieldNames = [fieldNames];
	    	}	
	    	var cm = null;
	    	var cols = {}, minWidth = {};
	    	if(col == null) {	    		
		    	for(var i = 0, rlen = this.option.colModels.length; i < rlen; i++) {
		    		cm = this.option.colModels[i];
		    		if(isall) {		    			
		    			if(cm.hidden != true && cm.contentFit === true) {
		    				fieldNames.push(cm.name);
		    				cols[cm.name] = this.titleCol[i];
			    			minWidth[cm.name] = this._getNumberValue(cm.minWidth, 0);
		    			}
		    		} else {
			    		for(var j = 0, clen = fieldNames.length; j < clen; j++) {
				    		if(cm.hidden != true && cm.name == fieldNames[j]) {
				    			cols[cm.name] = this.titleCol[i];
				    			minWidth[cm.name] = this._getNumberValue(cm.minWidth, 0);
				    		}
			    		}
		    		}
		    	}
	    	} else if(!(this.isArray(col))) {
	    		cols[fieldNames[0]] = col;
	    		minWidth[fieldNames[0]] = this.getColModel(fieldNames[0]).minWidth;
	    	}
	    	var _grid = this;
	    	if(fieldNames.length > 0) {
	    		var listWidth = _grid._getNumberValue(_grid.listDiv.style.width);
	    		var gridWidth = _grid._getNumberValue(_grid.gridTable.style.width);
	    		this.getMaxText(fieldNames, function(fieldNames, maxText) {
	    			for(var j = 0, clen = fieldNames.length; j < clen; j++) {
	    				 var fn = fieldNames[j];
		    			 var curCol = cols[fn];
		    			 if(curCol == null) continue;
		    			 var cp = $(curCol).text();
		    			 if(cp === "" && curCol.checkBox != null) {
		    				 cp += ".";
		    			 }
		    			 var smy = _grid.dataSet.getSummary(fn);
		    			 var smw = 0;
		    			 if(smy != null && smy !== "") {
		    				 smy = _grid.dataSet.getDisplay(fn, smy);
		    				 smw = _grid.getTextWidth(smy, "14px", "bold") + 8;
		    			 }
		    			 var cw = _grid.getTextWidth(cp, "14px", "bold") + 8;
		    			 var nw = _grid.getTextWidth(maxText[fn]) + 8;
		    			 if(nw < cw) {
		    				 nw = cw;
		    			 }
		    			 if(smw > nw) {
		    				 nw = smw;
		    			 }
		    			 if(_grid.treeGrid != false && curCol.option.cIndex == 0) {
		    				 nw += _grid.maxLevel * 16 + 16;
		    				 if(_grid.multiSelect) {
		    					 nw += 12;
		    				 }
		    			 }
		    			 if(minWidth[fn] != null && nw < minWidth[fn]) {
		    				 nw = minWidth[fn];
		    			 }
		    			 var oldWidth = curCol.offsetWidth;
		    			 if(oldWidth > 0) {
		    				 if(_grid.getOption().shrinkToFit && _grid._oldGridWidth != null 
		    						 && _grid._oldGridWidth < _grid._width 
		    						 && gridWidth < listWidth && oldWidth > nw) {
		    					 continue;
		    				 }
		    			     _grid._setColWidth(curCol, nw - oldWidth, [oldWidth], 
		    			         _grid._getNumberValue(_grid.gridTable.style.width, 1));
		    			 }
	    			 }
	    			 _grid._suitTitleHeight();	  
	    			 _grid._oldGridWidth = null;
	    			 _grid._tmpWidth = null;
	    			 if(typeof callBack === "function") {
	    				 callBack.apply(_grid);
	    			 }
	    		});
	    	} else if(typeof callBack === "function") {
		        callBack.apply(_grid);
	        }
	    },
	    /**
         * 标题双击事件
         * @name doTitleDBClick
         */
	    doTitleDBClick:function(sender, ev) {
	    	if(this.resizeState) {
	    		if(sender.option.isBand) {
	    			
	    		} else {
		    		var ci = sender.option.cIndex  + 1 + this._colIndexDeff();
		    		var cm = this._getColModel(ci);
		    		this.setContentFit(cm.name, sender);
	    		}
	    	}
	    },
	    /**
	     * 执行标题鼠标按下事件.
	     * @param sender 控件对象
	     * @param ev 事件对象
	     */
	    doTitleMouseDown:function(sender, ev) {
	    	if(this.getMouseButton(ev) == this.mouseType.mtLeft && !this.sortClick) {
		    	this.titleMouseDown = true;
		        this.curTitleCell = sender;
		        this.curTitleCellWidth = this._getColWidth(sender);
		        this.curTableWidth = this.gridTable.offsetWidth;
		        this.curFzTableWidth = this.fzGridTable.offsetWidth;
		        this.curMouseLeft = this.mouseLeft;
		        this._isHScrollHide = this.getHScrollHide();
	        }
	    	this.post();
    		if(!this.focus) {
    			this.setFocus();
    		}
	    },
        /**
         * 执行标题鼠标弹起事件.
	     * @param sender 控件对象
	     * @param ev 事件对象
         */	    
	    doTitleMouseUp:function(sender, ev) {
	    	if(this.getMouseButton(ev) == this.mouseType.mtLeft && !this.sortClick && !this.resizeState) {
		    	if(this.titleMouseDown && !this.titleDragState
		    			&& this.curTitleCell.cellIndex == sender.cellIndex 
		    			    && this.curTitleCell.parentNode.rowIndex == sender.parentNode.rowIndex) {
		    		//选择列
		    		if(sender.cellIndex == this._colOrder["@INDEX"] && sender.option.cIndex == -1) {
		    			this.colIndex = 1 + this._colIndexDeff();
		    			this.selRect.beginColIndex = 1 + this._colIndexDeff();
		    			this.selRect.endColIndex = this.colCount - 1;
		    		} else {
				    	this.selRect.beginColIndex = sender.option.cIndex + 1 + this._colIndexDeff();
				    	this.selRect.endColIndex = sender.option.cIndex + parseInt(sender.getAttribute("colSpan"), 10) + this._colIndexDeff();
				    	this.colIndex = sender.option.cIndex + 1 + this._colIndexDeff();		    			
		    		}		    			
		    		this.dataSet.beginUpdate();
		    		this.dataSet.last();
		    		this.selRect.endRowNode = this.dataSet.getCurNode();
		    		this.dataSet.first();
		    		this.selRect.beginRowNode = this.dataSet.getCurNode();	    		
		    		this.dataSet.endUpdate(false);
		    		//点表头时直接进入焦点.
		    		if(!this.focus) {
		    			this.setFocus();
		    		}
		    		this.refresh();
		    	}	
	    	} else if(this.resizeState){
	    		this.refresh();
	    	}
	    	this.trigger("onHeaderClick",[]);
	    },
	    /**
	     * 执行标题鼠标移动事件.
	     * @param sender 控件对象
	     * @param ev 事件对象
	     */
	    doTitleMouseMove:function(sender, ev) {
	    	if(!this.titleMouseDown) {   
	    		var sleft = 0;
		        if (this.isEmpty(sender.mainCell)) {
		            sleft = this.listDiv.scrollLeft;
		        }
		        var oRect = sender.getBoundingClientRect();
			    var disX = ev.clientX + sleft;
		        var w = sender.offsetWidth;
		        var vr = w - (ev.clientX - oRect.left);
		        if (vr < 10) {
		        	this.resizeState = true;
		        	this.titleDragState = true;
		        	if(this.getBrowser("safari")) {
		        		this.thisWindow.style.cursor = "e-resize";
		        	} else {
		        		this.thisWindow.style.cursor = "col-resize";		        		
		        	}
		        } else {
		        	this.titleDragState = false;
		        	this.resizeState = false;
		        	this.thisWindow.style.cursor = "";
		        }
		        this.mouseLeft = ev.clientX;
		        sleft = null;
		        oRect = null;
		        disX = null;
		        w = null;
		        vr = null;
	        } //else if(this.titleMouseDown && !this.focus) {
		     //   this.doMouseMove(ev);	        	
	        //}
	    },
	    /**
	     * 执行标题鼠标移过事件.
	     * @param sender 控件对象
	     * @param ev 事件对象
	     */
	    doTitleMouseOver:function(sender, ev) {
	    	if(this.titleMouseDown && !this.titleDragState) {
	    		if(this.curTitleCell.option.cIndex <= sender.option.cIndex) {
	    			this.selRect.beginColIndex = this.curTitleCell.option.cIndex + 1 + this._colIndexDeff();
	    			this.selRect.endColIndex = sender.option.cIndex + this._getNumberValue(sender.getAttribute("colSpan"), 1) + this._colIndexDeff();
	    		} else {
	    			this.selRect.beginColIndex = sender.option.cIndex + 1 + this._colIndexDeff();
	    			this.selRect.endColIndex = this.curTitleCell.option.cIndex + 1 + this._colIndexDeff();
	    		}
	    		if(this.selRect.beginColIndex < 1) {
	    			this.selRect.beginColIndex = 1;
	    		}
	    		this.colIndex = this.curTitleCell.option.cIndex + 1 + this._colIndexDeff();
	    		this.dataSet.beginUpdate();
	    		this.dataSet.last();
	    		this.selRect.endRowNode = this.dataSet.getCurNode();
	    		this.dataSet.first();
	    		this.selRect.beginRowNode = this.dataSet.getCurNode();	    		
	    		this.dataSet.endUpdate(false);
	    		this.refresh();
	    	}
	    },
	    /**
	     * 执行单元格鼠标按下事件.
	     * @param sender 控件对象
	     * @param ev 事件对象
	     */
	    doCellMouseDown:function(sender, ev) {
	    	if(this.getMouseButton(ev) == this.mouseType.mtLeft) {
	    		var nrf = false;
	    		if(this.focus == false) {
	    			nrf = true;
	    		}
		    	this.cellMouseDown = true;
		    	var canSelectRow = true;
		    	//换行事件
		    	if(this.dataSet.getRecordCount() >= 1 && nrf === true && this.hasbind("beforeSelectRow") === true) {
		    		var nNode = sender.parentNode._node;
		    		var cNode = this.dataSet.getCurNode();
		    		if(nNode.recNo != cNode.recNo) {
			    		if(this.trigger("beforeSelectRow",[cNode, nNode]) !== false) {
			    			this.curCell = sender;
			    		} else {
		    			    	canSelectRow = false;
		    			}
		    		} else {
		    			this.curCell = sender;
		    		}		    		
		    	} else {
		    		this.curCell = sender;
		    	}		    		    	
		    	if(this.curCell != null && this.curCell.cellIndex == this._colOrder["@INDEX"]) {
		    		this.selARow = true;
		    	} else {
		    		this.curColIndex = sender.cellIndex;
		    	}
		    	if(this.focus === false) {
		    		//this.post();
		    		this.setFocus();
		    		if(nrf === true && this.inputFocus !== true && canSelectRow === true) {
		    			this.refresh(true);
		    			//激活选择事件
		    			this.trigger("onCellSelect",[this.getPKeyName(),this.colIndex,this,ev]);
			    	    this.trigger("onSelectEcpRow",[this.getSelectRowIds(),this.getFieldName(),ev]);
		    			//焦点外的时候点第一次的时候触发一次。
		    			this.trigger("onClick", [this.dataSet.getCurNode(), this.getFieldName()]);
		    			//F1233769 从外部点选择单元格时，再点别一个单元格，头一次没有效果， 因此注释掉以下代码。 暂时不清除注释内容，
		    			this.isSelect = this.inputFocus;
		    		}
		    	}
	    	}
	    	this.logInfo("mouse down");
	    },
	    /**
	     * 刷新合并单元格的区域选择.
	     * @param groups 分组列列表
	     */
	    _refreshMulSelect:function(groups) {
			if(groups == null) {
				groups = [];
			}
			//处理合并行问题
			var glen = groups.length;
			if(glen > 0) {				
				this.dataSet.beginUpdate();
				var cn = this.dataSet.getCurNode();
    			//向上选择
    			var pcn = this.selRect.beginRowNode;
    			this.dataSet.select(pcn);
    			same = true;
    			//收集所有合并列的值
    			groupValue = {}, plevel=0;
    			for(var j = 0; j < glen; j++) {
					var fieldName = groups[j];
					groupValue[fieldName] = this.dataSet.getDisplay(fieldName);
				}
    			plevel = this.dataSet.getLevel();
    			//往前遍历
    			this.dataSet.prior();
    			while(!this.dataSet.isBof() && same) {
    				var sms = false;
    				//获得节点level
    				var clevel = this.dataSet.getLevel();
    				//是否同级
    				if(plevel == clevel) {
    					//循环分组例
	    				for(var j = 0; j < glen; j++) {
	    					var fieldName = groups[j];
	    					var cm = this.getColModel(fieldName);
	    					//获得显示值
	    					var cval = this.dataSet.getDisplay(fieldName);
	    					//前后时否一样
	    					sms = sms || (cm.groupsEmpty === true 
	    							|| cm.groupsEmpty !== true && cval != null && cval !== "") 
	    					   && cval === groupValue[fieldName];
	    					groupValue[fieldName] = cval;
	    				}
    				}
    				plevel = clevel;
    				//是否有一样
    				same = same && sms;
    				if(same) {
    					pcn = this.dataSet.getCurNode();
    				}
    				this.dataSet.prior();
    			}
    			//选择区域最前行节点指向当前行
    			this.selRect.beginRowNode = pcn;
    			//向下选择
				var ccn = this.selRect.endRowNode;
    			this.dataSet.select(ccn);
    			var same = true;
    			//收集所有合并列的值
    			var groupValue = {}, plevel=0;
    			for(var j = 0; j < glen; j++) {
					var fieldName = groups[j];
					groupValue[fieldName] = this.dataSet.getDisplay(fieldName);
				}
    			//获得当前节点level
    			plevel = this.dataSet.getLevel();
    			this.dataSet.next();
    			while(!this.dataSet.isEof() && same) {
    				var sms = false;
    				//获得当前节点level
    				var clevel = this.dataSet.getLevel();
    				if(plevel == clevel) {
	    				for(var j = 0; j < glen; j++) {
	    					var fieldName = groups[j];
	    					var cm = this.getColModel(fieldName);
	    					//获得显示值
	    					var cval = this.dataSet.getDisplay(fieldName);
	    					//前后时否一样
	    					sms = sms || (cm.groupsEmpty === true 
	    							|| cm.groupsEmpty !== true && cval != null && cval !== "") 
	    					   && cval === groupValue[fieldName];
	    					groupValue[fieldName] = cval;
	    				}
    				}
    				plevel = clevel;
    				//是否有一样
    				same = same && sms;
    				if(same) {
    					ccn = this.dataSet.getCurNode();
    				}
    				this.dataSet.next();
    			}
    			//选择区域最后行节点指向当前行
    			this.selRect.endRowNode = ccn;
    			//重新定位到原来的行
    			this.dataSet.select(cn);
    			this.dataSet.endUpdate(false);
			}
	    },
	    /**
	     * 执行单元格鼠标移过事件.
	     * @param sender 控件对象
	     * @param ev 事件对象
	     */
	    doCellMouseOver:function(sender, ev) {
	    	if(this._enabled != false && this.cellMouseDown && this.curCell != null) {
	    		var rsp = 0;
	    		if(sender.cellIndex > 0) {
	    			//选择列
		    		if(this.curCell.cellIndex <= sender.cellIndex) {
		    		    this.selRect.beginColIndex = this.curCell.cellIndex
		    		    this.selRect.endColIndex = sender.cellIndex;
		    		} else {
		    			this.selRect.beginColIndex = sender.cellIndex;
		    		    this.selRect.endColIndex = this.curCell.cellIndex;
		    		}
		    		if(this.selRect.beginColIndex <= 0) {
		    			this.selRect.beginColIndex = 1;
		    		}
		    		this.colIndex = this.curCell.cellIndex;		    		
	    		} else {
	    			if(this.selARow) {
		    			this.selRect.beginColIndex = 1 + this._colIndexDeff();
		    			this.selRect.endColIndex = this.colCount - 1;
		    			this.colIndex = 1 + this._colIndexDeff();
	    			}
	    		}
	    		var groups = [];
	    		//计算最下面的列
	    		for(var j = this.selRect.beginColIndex; j <= this.selRect.endColIndex; j++) {
	    			var cm = this._getColModel(j);
	    			if(cm.groups === true) {
	    				groups.push(cm.name);
	    			}
	    		}
	    		var cNode = null;
	    		if(this.curCell != null) {
	    			cNode = this.curCell.parentNode._node;
	    		}
	    		var sNode = sender.parentNode._node;
	    		//选择行
	    		if(cNode != null) {
	    			if(cNode.getIndex() < sNode.getIndex()) {
		    			this.selRect.beginRowNode = cNode;
		    		    this.selRect.endRowNode = sNode;
		    		} else {
		    			this.selRect.beginRowNode = sNode;
		    		    this.selRect.endRowNode = cNode;
		    		}
	    			this._refreshMulSelect(groups);
		    	}
	    		this.post();
	    		if(cNode != null) {
	    		    this.dataSet.select(cNode);
	    		}
	    		this.isCellMouseOver = true;
	    		this.refresh();
	    	}
	    },
	    doMouseDown:function(ent) {
	    	this.base(ent);
	    	//拖动横向滚动条用.
	    	this.scrollMouseDown = true;
	    	this.isCellMouseOver = false;
	    },
	    /**
	     * 执行鼠标弹起事件.
	     * @param ent 事件对象
	     */
        doMouseUp:function(ent) {
	    	this.base(ent);
	    	this.scrollMouseDown = false;
	    	this.scrollBar.ismousedown = false;
	    	this.dataSet.initMaxText(); 
	    	if(this.getMouseButton(ent) == this.mouseType.mtRight && this.hasSelect) {
	    		if(this.getOption().hidePopMenu || this.popMenu._popCount == 0) {
	    			return;
	    		}
	    		var ixy = this.getScrollXY();
	    		var iy = ent.clientY + ixy.top;
	        	var ix = ent.clientX + ixy.left;
	        	if(typeof(this.onPopMenuExt) == "function") {
	        		this.onPopMenuExt(this, this.popMenu);
	        	}
	        	this.trigger("onPopMenuExt", [this, this.popMenu]);
	    		this.popMenu.execute(iy, ix);
	    	} else {
	    		//各事件状态
	    	    if(this.curTitleCell != null) {
		    	    var oRect = this.curTitleCell.getBoundingClientRect();
		    	    var w = this.curTitleCell.offsetWidth;
				    var vr = w - (ent.clientX - oRect.left);
				    if (vr >= 5) {
		        	    this.thisWindow.style.cursor = "";
		        	}
				    this._gridTableHeight = null;
				    this._refreshSumTab();
				    oRect = null;
			    } else {
			    	this.thisWindow.style.cursor = "";
			    }			    
	        	this.titleMouseDown = false;
	        	this.titleDragState = false;
	        	this.curTitleCell = null;
//	        	if(this.focus === false) {
//	        		this.setFocus();
//	        	}
	        	if(this._hasScroll !== true && this.cellMouseDown && !this.inputFocus) {
	        		this.copyInput.select();
	        		this.copyInput.focus();
	        	}
	        	this.cellMouseDown = false;
	        	this.selARow = false;
	        	this.sortClick = false;
		    	this.curCell = null;
		    	var isHSH = this.getHScrollHide();
		    	if(this._isHScrollHide != null && isHSH != this._isHScrollHide) {
		    	     this.initGrid();
		    	     this.refresh();
		    	}
		    	this._isHScrollHide = isHSH;
		    	if(this._hasScroll === true) {
		    		//表格拖动滚动条的时候，数据丢失
		    		if(this.inputFocus && this.editObject != null) {
		    			this.post();
		    		}
		    		this.refresh();
		    	}
		    	this._hasScroll = false;
	    	}
	    },
	    /**
	     * 获取原列宽度.
	     * @param titleCol 传入的列对象
	     */
	    _getColWidth:function(titleCol) {
	    	var colsWidth = [];
	    	var colSpan = parseInt(titleCol.getAttribute("colSpan"), 10);
	    	if(colSpan > 0) {	 
			    //原来多列，隐藏后就不对了
			    var k = 0;
	        	for(var i = 0; i < colSpan; i++) {
					var tc = this.gridTable.rows[0].cells[titleCol.option.cIndex + 1 + i + k + this._colIndexDeff()];
					while(tc.style.display == "none") {
						k++;
						tc = this.gridTable.rows[0].cells[titleCol.option.cIndex + 1 + i + k + this._colIndexDeff()];
					}
	        		colsWidth[i] = this._getNumberValue(tc.style.width, 0);
	        	}
	        }
	    	return colsWidth;
	    },
	    /**
	     * 通过下标获取当前列的宽度.
	     * @name getColWidth
	     * @param {number} colIndex
	     * @example 
	     *    width = grid.getColWidth(1);
	     * @return {number} colWidth 列宽
	     */
	    getColWidth:function(colIndex, def) {
	    	if(def == null) {
	    		def = 1;
	    	}
	    	return this._getNumberValue(this.gridTable.rows[0].cells[colIndex].style.width, def);
	    },
	    /**
	     * 表格列宽设置。
	     */
	    setColWidth:function(fieldName, width) {
	    	for(var i = 0, len = this.gridTable.rows[0].cells.length; i < len; i++) {
	    		var topCell = this.gridTable.rows[0].cells[i];
	    		if(topCell.option != null) {
		    		var col = topCell.option.fzCol;
		    		var cm = topCell.option.colModel;
		    		if(cm != null) {
			    		if(col == null) {
			    			col = topCell;
			    		}
			    		if(cm.name === fieldName) {
				    		var addWidth = parseInt(width, 10) - cm.width;
				    		if(addWidth != 0) {
				    		    this._refreshCellDivWidth(col.cellIndex, topCell.option.defWidth);
				    		    this._setGridTableWidth(this._getNumberValue(this.gridTable.style.width) + addWidth);
				    		}
				    		break;
			    		}
		    		}
	    		}
	    	}
	    },
	    _getShrinkCol:function(noDef) {
	    	var gridWidth = 0;
	    	var count = 0;
	    	var colObjs = [];
	    	for(var j = 1, clen = this.titleCol.length; j <= clen; j++) {
	    		var cm = this.option.colModels[j - 1];
	    		var col = this.titleCol[j - 1];
	    		if(cm.hidden !== true && cm.hidden !== "true") {	    			
	    			var w = this.getColWidth(col.option.cIndex + 1 + this._colIndexDeff(), cm.width);
	    		    gridWidth += w;
	    		    if(noDef == true || cm.defWidth && cm.contentFit != true) {
	    		        count ++;
	    		        colObjs.push({
	    		        	"col":col,
	    		        	"width":w
	    		        });
	    		    }
	    		}
	    	}
	    	if(this.getOption().rownumbers) {
	    		gridWidth += 60;
	    	}
	    	if(this.treeGrid == false && this.multiSelect == true) {
	    		gridWidth += 30;
	    	}
	    	return {"gridWidth":gridWidth,"count":count,"cols":colObjs};
	    },
	    resetColWidth:function() {
	    	for(var i = 0, len = this.gridTable.rows[0].cells.length; i < len; i++) {
	    		var topCell = this.gridTable.rows[0].cells[i];
	    		if(topCell.option != null) {
		    		var col = topCell.option.fzCol;
		    		var cm = topCell.option.colModel;
		    		if(cm != null) {
			    		if(col == null) {
			    			col = topCell;
			    		}
			    		var addWidth = topCell.option.defWidth - cm.width;
			    		if(addWidth != 0) {
			    		    this._refreshCellDivWidth(col.cellIndex, topCell.option.defWidth);
			    		    this._setGridTableWidth(this._getNumberValue(this.gridTable.style.width) + addWidth);
			    		}
		    		}
	    		}
	    	}
	    },
	    suitToFit:function() {
	    	this.shrinkToFit(null, true);
	    },
    	/**
	     * 填充空白处.
	     */
	    _shrinkToFit:function(state) {
	    	 this.shrinkToFit(state);
	    },	    
	    /**
	     * 填充空白处.
	     */
	    shrinkToFit:function(state, suit) {
	    	if(this._tmpWidth == this.getOption().width 
	    			&& this._tmpScrollVisible == this.scrollBar.visible && state !== true && suit !== true) {
	    		return;
	    	}
			this._tmpWidth = this.getOption().width;
			this._tmpScrollVisible = this.scrollBar.visible;
	        //计算宽度
	    	var sc = this._getShrinkCol();
	    	var gridWidth = sc.gridWidth;
	    	var count = sc.count;
	    	var colObjs = sc.cols;
	    	sc = null;
	    	var width = this.getBoxWidth();
	    	if(width < this.getWidth()) {
	    		width++;
	    	}
	    	if(this._oldGridWidth == null) {
    	    	this._oldGridWidth = gridWidth;
	    	}
	    	var scrollWidth = 1;
	    	var fitWidth = scrollWidth + 1;
	    	//重新分配宽度
	    	if(suit === true || gridWidth <= width - fitWidth 
                     || suit === true && this._oldGridWidth != null && this._oldGridWidth  < width - fitWidth) {
	    		if(count == 0) {
	    			sc = this._getShrinkCol(true);
	    			gridWidth = sc.gridWidth;
	    			count = sc.count;
	    			colObjs = sc.cols;
	    			sc = null;
	    			if(!(suit === true || gridWidth <= width - fitWidth 
                     || this._oldGridWidth != null && this._oldGridWidth  < width - fitWidth)) {
	    				count = 0;
	    			}
	    		}
		    	if(count > 0) {
		    	    var avgWidth = parseInt((width - gridWidth - fitWidth)/count, 10);
                    var subWidth = width - gridWidth - fitWidth - avgWidth * count;
                    subWidth = parseInt(subWidth, 10);
		    	    for(var j = 0; j < count; j++) {
		    	    	var colobj = colObjs[j];
                        var subDiv = 0;
                        if(subWidth > 0) {
                            subDiv = 1;
                            subWidth --;
                        } else if(subWidth < 0) {
                        	subDiv = -1;
                        	subWidth ++;
                        }
		    	    	this._setColWidth(colobj.col, avgWidth + subDiv, [colobj.width], gridWidth);
		    			gridWidth += avgWidth + subDiv;
		    	    }
		    	    this._asynRun(function(){
		    	    	if(typeof this.refresh == "function") {
		    	    	    this.refresh();
		    	    	    this.refreshVScrollBar();
		    	    	}
		    	    }, 10);
		    	}
	    	}
	    	colObjs = null;
	    },
	    /**
	     * 刷新单元格列宽.
	     * @name _refreshCellDivWidth
	     * @param {number} colIndex 列序号
	     * @param {number} newWidth 列宽
	     * @ignore
	     */
	    _refreshCellDivWidth:function(colIndex, newWidth) {
	    	if(colIndex === this._colOrder["@INDEX"] && newWidth < 55) {
	    		return;
	    	}
	    	//冻结列
	    	var topCol = this.fzGridTable.rows[0].cells[colIndex];
	    	if(topCol != null && topCol.noUse !== true && newWidth > 0) {
	    		this._setNumberValue(topCol, "width", newWidth);
	    		if(this.getOption().footerrow == true || this.getOption().total === true) {
	    			var scls = this.fzSumTable.rows[this.totalIndex].cells[colIndex];
	    			this._setNumberValue(scls.rect.text, "width", (newWidth - 8));
	    			this._setNumberValue(scls.rect, "width", (newWidth - 8));
	    		    this._setNumberValue(scls, "width", newWidth);
	    		    scls = null;
	    		}
	    		if(this.getOption().subtotal === true) {
	    			var scls = this.fzSumTable.rows[this.subtotalIndex].cells[colIndex];
	    			this._setNumberValue(scls.rect.text, "width", (newWidth - 8));
	    			this._setNumberValue(scls.rect, "width", (newWidth - 8));
	    		    this._setNumberValue(scls, "width", newWidth);
	    		    scls = null;
	    		}
	    	}
	    	topCol = null;
	    	//非冻结列
	    	if(newWidth > 0) {
	    		var rcell = this.gridTable.rows[0].cells[colIndex];
	    		if(rcell != null) {
	    			this._setNumberValue(rcell, "width", newWidth);
		    	    if(this.getOption().footerrow == true || this.getOption().total === true) {
		    	    	var scls = this.sumTable.rows[this.totalIndex].cells[colIndex];
		    	    	this._setNumberValue(scls.rect.text, "width", (newWidth - 8));
		    	    	this._setNumberValue(scls.rect, "width", (newWidth - 8));
		    	        this._setNumberValue(scls, "width", newWidth);
		    	        scls = null;
		    	    }
	    		}
	    	    if(this.getOption().subtotal === true) {
	    	    	var scls = this.sumTable.rows[this.subtotalIndex].cells[colIndex];
	    	    	var nnw = newWidth - 8;
	    	    	this._style(scls.rect.text,"width", nnw + "px");
	    	    	this._style(scls.rect,"width", nnw + "px");
	    	    	this._style(scls,"width", newWidth + "px");
	    	        scls = null;
	    	    }
	    	}
	    	var mulW = 0;
	    	if(this.multiSelect) {
	    		mulW = 10;
	    	}
	    	var fieldName = this.getFieldName(colIndex);
        	for(var i = 0, rlen = this.sheets.length; i < rlen; i++) {
	    		var row = this.sheets[i].row;
	    		var fzRow = this.fzSheets[i].row;
	    		var fcol = fzRow.cells[colIndex];	    		
	    		if((this.getOption().treeKey==null&& colIndex === 1 || this.getOption().treeKey === fieldName)
	    				 && this.option.treeGrid != false) {	  
	    			var rcell = row.cells[colIndex];
	    			if(rcell != null) {
		    			if(newWidth - 8 > 0) {
			    			rcell.levelDiv.style.width = (newWidth - 8) + "px";	    		
				    		if(fcol != null && fcol.noUse !== true) {
				    			fcol.levelDiv.style.width = (newWidth - 8) + "px";
				    		}
		    			}
			    		var lvtd = newWidth - 8 - 14 - mulW - this._getNumberValue(rcell.levelTd.style.width, 0);
				    	if(lvtd > 0) {
				    		rcell.rect.style.width = lvtd + "px";
				    		rcell.rect.text.style.width = lvtd + "px";
				    		if(fcol != null && fcol.noUse !== true) {
				    			fcol.rect.style.width = lvtd + "px";
				    			fcol.rect.text.style.width = lvtd + "px";
				    		}
			    		}
	    			}
	    		} else {
	    			if(newWidth - 8 > 0) {
	    				var rcell = row.cells[colIndex];
	    				if(rcell != null) {
	    					rcell.rect.style.width = (newWidth - 8) + "px";
	    					rcell.rect.text.style.width = (newWidth - 8) + "px";
				    		if(fcol != null && fcol.noUse !== true) {
				    			fcol.rect.style.width = (newWidth - 8) + "px";
				    			fcol.rect.text.style.width = (newWidth - 8) + "px";
				    		}
	    				}
	    			}
	    		}
	    		row = null;
	    		fzRow = null;
        	}
        	this._getColModel(colIndex).width = newWidth;
	    },
	    /**
	     * 设置列宽度.
	     * @param titleCol 列对象， 
	     * @param width 宽度
	     * @param oldWidth 原宽度
	     */
	    _setColWidth:function(titleCol, addWidth, oldWidth, oldGridWidth) {
	    	var colSpan = parseInt(titleCol.getAttribute("colSpan") || 1, 10);
	    	var avgWidth = parseInt(addWidth/colSpan, 10);
	        var i = 0;
	        var sumWidth = 0;
	        var realWidth = 0
			var k = 0;
			var tc = null;			
	        for(; i < colSpan - 1; i++) {
				tc = this.gridTable.rows[0].cells[titleCol.option.cIndex + 1 + i + k + this._colIndexDeff()];
				while(tc.style.display == "none") {
					k++;
					tc = this.gridTable.rows[0].cells[titleCol.option.cIndex + 1 + i + k + this._colIndexDeff()];
				}
				tc = null;
	        	//平均分配宽度
	        	sumWidth += avgWidth;
	        	var newWidth = oldWidth[i] + avgWidth;
	        	//调整单元格中的div宽
	        	this._refreshCellDivWidth(titleCol.option.cIndex + 1 + i + k + this._colIndexDeff(), newWidth);        	
	        	realWidth += newWidth - oldWidth[i];
	        }
			tc = this.gridTable.rows[0].cells[titleCol.option.cIndex + 1 + i + k + this._colIndexDeff()];
			while(tc != null && tc.style.display == "none") {
				k++;
				tc = this.gridTable.rows[0].cells[titleCol.option.cIndex + 1 + i + k + this._colIndexDeff()];
			}
			tc = null;
	        //最后一列用总宽减去之前的宽的和
	        var newWidth = oldWidth[i] + (addWidth - sumWidth);
	        if(newWidth < 0) {
	        	return;
	        }
	        //调整输入控件
	        realWidth += newWidth - oldWidth[i];
	        //调整单元格中的div宽
        	this._refreshCellDivWidth(titleCol.option.cIndex + 1 + i + k + this._colIndexDeff(), newWidth);
        	this._setGridTableWidth(oldGridWidth + realWidth);
        	this.refreshVScrollBar();
	        //this._setNumberValue(this.gridTable, "width", (oldGridWidth + realWidth));
	        //this._setNumberValue(this.sumTable, "width", (oldGridWidth + realWidth));
	    },
	    /**
	     * 调整固定称标题行高.
	     * @name _suitTitleHeight
	     * @ignore
	     */
	    _suitTitleHeight:function() {
	    	var that = this;
	    	this._asynRun(function(){
                if(this.gridTable == null || this.gridTable.rows.length == 0) return;
	    		var gridTableOH = this.gridTable.rows[1].cells[0].offsetHeight;
		        if(gridTableOH > 0 && 
		        		gridTableOH != this.fzGridTable.rows[1].cells[0].offsetHeight) {
		        	//box-size样式控制后，就没有差异了
		        	var fzHeight = gridTableOH;// - this._addDeff(1);
		        	this.fzGridTable.rows[1].cells[0].style.height = fzHeight + "px";
		        	if(this.fzGridTable.rows[1].cells[0].offsetHeight <= 0) {
		        		this.fzGridTable.rows[1].style.height = fzHeight + "px";
		        	}
		        	var deff = gridTableOH - this.fzGridTable.rows[1].cells[0].offsetHeight;
		        	if(deff != 0) {
		        		this.fzGridTable.rows[1].cells[0].style.height = (fzHeight + deff) + "px";
		        	}
		        	this.refresh();
		        }	    		
	    	}, 10);
	    },
	    /**
	     * 执行鼠标移动事件.
	     * @param ent 事件对象
	     */
	    doMouseMove:function(ev) {
	    	this.mouseLeft = ev.clientX;	    	
	    	if(this.titleMouseDown && this.titleDragState) {	    		
	    		var disX = this.mouseLeft - this.curMouseLeft;	
		        var cm = this._getColModel(this.curTitleCell.option.cIndex + 1 + this._colIndexDeff());
		        if(cm.dataType == "number" || cm.dataType == "money") {
		        	var _grid = this;		        		
		        	this.getMaxText([cm.name], function(fieldNames, maxText) {
	    				 var fn = fieldNames[0];			    			 
		    			 var smy = _grid.dataSet.getSummary(fn);
		    			 var smw = 0;
		    			 if(smy != null && smy !== "") {
		    				 smy = _grid.dataSet.getDisplay(fn, smy);
		    				 smw = _grid.getTextWidth(smy, "14px", "bold") + 8;
		    			 }
		    			 var nw = _grid.getTextWidth(maxText[fn]) + 8;
		    			 if(smw > nw) {
		    				 nw = smw;
		    			 }
		    			 _grid._maxTextLen = nw;
		    			 if(disX + _grid.curTitleCellWidth[0] < nw) {
		    				 disX = nw - _grid.curTitleCellWidth[0] + 8;
		    			 }
		    			 _grid._setColWidth(_grid.curTitleCell, disX, _grid.curTitleCellWidth, _grid.curTableWidth);
		    			 _grid._suitTitleHeight();
		    			 _grid.refreshScrollBar();
		    		}, true);
		        } else {
		            this._setColWidth(this.curTitleCell, disX, this.curTitleCellWidth, this.curTableWidth);
		            this._suitTitleHeight();
		        	this.refreshScrollBar();
		        }		        
	    	}
	    	return false;
	    },    
	    /**
	     * 设置剪贴板.
	     */
	    setClipboard:function(text) {
	    	if (navigator.userAgent.indexOf("MSIE")>0 == true) {	//浏览器为IE
				window.clipboardData.setData("text", text);
				return true;
			} else if (navigator.userAgent.indexOf("Firefox")>0 == true) {		//浏览器为Firefox
				try {
					netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect'); 
				} catch(e) {
//					alert("您的复制操作因设置问题而未生效，请依以下步骤进行设置\n"
//						+ "1. 请在地址栏输入 about:config 并按下enter\n"
//						+ "2. 请于[signed.applets.codebase_principal_support]首选项点击鼠标右键切换值为true\n\n然后重试复制！");
                    alert(this.getI18n("qzz.copyMsg", "因当前浏览器的剪贴板无法控制，请在IE上使用该功能。"));
					return;
				}
				var clip = Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard); 
				if (!clip) {
					clip = null;
					return;
				}	
				var trans = Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable);
				if (!trans) {
					trans = null;
					clip = null;
					return;
				}			
				trans.addDataFlavor('text/unicode'); 
				var str = new Object(); 
				var len = new Object(); 
				var str = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);
				var copytext = text;
				str.data = copytext; 
				trans.setTransferData("text/unicode",str,copytext.length*2); 
				var clipid = Components.interfaces.nsIClipboard; 
				if (!clipid ) {
					trans = null;
					clip = null;
					clipid = null;
					return;
				}				
				clip.setData(trans,null,clipid.kGlobalClipboard);				
				trans = null;
				clip = null;
				clipid = null;
				str = null; 
				len = null; 
				str = null;
				copytext = null;
			}
	    },
	    /**
	     * 设置复制数据.
	     * @return 返回字符串
	     */
	    getCopyData:function() {
	    	//是否区域选择
	    	if(this.mulCellSelect) {
	    		//this.dataSet 是表格控件的数据模型
	    		//缓存当前选择行
	    		var tmpNode = this.dataSet.getCurNode();
	    		//添加beginUpdate, endUpdate禁止获取数据过程中不刷新表格
	    		this.dataSet.beginUpdate();
	    		//区域选择的起始行设置为选择行
	    		this.dataSet.select(this.selRect.beginRowNode);
	    		//复制的数据内容数组
	    		var copyStr = [];
	    		//获取列模型
	    		var colModel = this.option["colModels"];
	    		var ri = 0;
	    		//从起始行到结束行循环数据模型，
	    		while (!this.dataSet.isEof() && this.dataSet.getIndex() <= this.selRect.endRowNode.getIndex()) {
	    			var rowStr = [];
	    			//从起始列到结束列循环数据模型
	    			for(var j = this.selRect.beginColIndex - 1,ci = 0; j <= this.selRect.endColIndex - 1; j++) {
	    				//获取数据模型
	    				var cm = this._getColModel(j + 1);
	    				//判断是否是显示列
	    				if(cm.name != null && cm.hidden != true) {
	    					//获取单元格显示的数据
		    				var cstr = this.dataSet.getDisplay(cm.name);
		    				//对特殊标签或字符进行转换
		    				if(typeof cstr === "string") {
		    					cstr = cstr.replace(/&gt;|&lt;/g, function(key){
			    					if(key === "&gt;") {
			    						return ">";
			    					} else {
			    						return "<";
			    					}
			    				});
		    				}
		    				//添加到列字符串数组中
		    				rowStr[ci++] = cstr === "" ? " ":cstr;
	    				}
	    			}
	    			//添加到行字符串数组中
	    			copyStr[ri++] = rowStr.join("\t");
	    			this.dataSet.next();
	    		}
	    		//还原选择行
	    		this.dataSet.select(tmpNode);
	    		//结束刷新控制
	    		this.dataSet.endUpdate(false);
	    		//把结果数组转换成字符串返回
	    		return copyStr.join("\n");
	    		tmpNode = null;
	    	} else {
	    		return this.dataSet.getDisplay(this.getFieldName());
	    	}
	    },
	    /**
	     * 获取显示的JSON字符串.
	     */
	    getDisplayAsJson:function(fieldNames, valOnly, escape) {	    	 
	    	 if(typeof fieldNames == "boolean") {
	    		 valOnly = fieldNames;
	    		 fieldNames = null;
	    	 }
	    	 if(valOnly == null) {
	    		 valOnly = false;
	    	 }
	    	 if(escape == null) {
	    		 escape = false;
	    	 }
	    	 var res = [];
	    	 if(this.dataSet.getRecordCount() > 0) {
	    	    var cn = this.dataSet.getCurNode();
	    	    this.dataSet.beginUpdate();
	    	    this.dataSet.first();
	    	    var colModel = this.getOption().colModels;
	    	    var len = colModel.length;
	    	    var fns = [];
	    	    if(this.isArray(fieldNames)) {
	    	    	fns = fieldNames;
	    	    } else {	    	    
		    	    for(var i = 0; i < len; i++) {
		    	    	var cm = colModel[i];
		    	    	if(!cm.hidden) {
		    	    		fns.push(cm.name);
		    	    	}
		    	    	cm = null
		    	    }
	    	    }
	    	    len = fns.length;
	    	    var levelSpace = {};
	    	    //循环获取数据
	    	    while(!this.dataSet.isEof()) {
	    	    	var cNode = this.dataSet.getCurNode();
	    	    	if(valOnly === false) {
		    	    	var rj = {};
		    	    	for(var i = 0; i < len; i++) {
		    	    		var val = this.dataSet.getDisplay(fns[i], null, null, null, escape);
		    	    		if(i == 0 && this.dataSet.isTree && cNode.level > 0) {
		    	    			var sj = levelSpace[cNode.level];
			    				if(sj == null) {
			    					sj = "";
				    				for(var k = 0; k < cNode.level; k++) {
				    					sj += "  ";
				    				}
				    				levelSpace[cNode.level] = sj;
			    				}
			    	    		val = sj + val;
			    	    	}
			    	    	rj[fns[i]] = val;
		    	    		cm = null;
		    	    	}
		    	    	res.push(rj);
		    	    	rj = null;
	    	    	} else {
	    	    		res.push(cNode.data);
	    	    	}	    	    	
	    	    	this.dataSet.next(true);
	    	    }
	    	    levelSpace = null;
	    	    this.dataSet.select(cn);
	    	    this.dataSet.endUpdate(false);
	    	 }
	    	 return res;
	    },	
		/**
		 * 获取显示的Array字符串.
		 * @param fieldNames 字段
		 * @param escape 是否转义, 默认不转义
		 */	    
	    getDisplayAsArray:function(fieldNames, escape) {
			 if(escape == null) {
				 escape = false;
			 }
	    	 var res = [];
	    	 if(this.dataSet.getRecordCount() > 0) {
	    	    var cn = this.dataSet.getCurNode();
	    	    this.dataSet.beginUpdate();
	    	    this.dataSet.first();
	    	    var colModel = this.getOption().colModels;
	    	    var len = colModel.length;
	    	    var fns = [];
	    	    if(this.isArray(fieldNames)) {
	    	    	fns = fieldNames;
	    	    } else {	    	    
		    	    for(var i = 0; i < len; i++) {
		    	    	var cm = colModel[i];
		    	    	if(!cm.hidden) {
		    	    		fns.push(cm.name);
		    	    	}
		    	    	cm = null
		    	    }
	    	    }
	    	    len = fns.length;
	    	    var levelSpace = {}; 
	    	    //循环获取数据
	    	    while(!this.dataSet.isEof()) {
	    	    	var cNode = this.dataSet.getCurNode();
	    	    	var rj = [];
	    	    	var j = 0;
	    	    	for(var i = 0; i < len; i++) {
		    	    	var val = this.dataSet.getDisplay(fns[i], null, null, null, escape);
		    	    	if(i == 0 && this.dataSet.isTree && cNode.level > 0) {
		    	    		var sj = levelSpace[cNode.level];
		    				if(sj == null) {
		    					sj = "";
			    				for(var k = 0; k < cNode.level; k++) {
			    					sj += "  ";
			    				}
			    				levelSpace[cNode.level] = sj;
		    				}
		    	    		val = sj + val;
		    	    	}
		    	    	rj[j++] = val;
	    	    	}
	    	    	res.push(rj);
	    	    	rj = null;
	    	    	this.dataSet.next(true);
	    	    }
	    	    levelSpace = null;
	    	    this.dataSet.select(cn);
	    	    this.dataSet.endUpdate(false);
	    	 }
	    	 return res;
	    },	
	    /**
	     * 获取表头和组.
	     * @param {boolean}hidden 是否获取隐藏列
	     */	     
	    getHeader:function(hidden, numberRow) {
	    	var cts = [],
	    		colModel = this.getOption().colModels,
	    		titleSheets = this.option.titleSheets;
	    	var rowLen = this.option.titleSheets.length;
	    	var xh = 0;
	    	if(numberRow == true && this.getOption().rownumbers) {
	    		xh = 1;
	    	}
	    	for(var i = 1; i < rowLen; i++) {
	    		cts[i - 1] = [];
	    		var pcts = null,
	    			colLen = titleSheets[i].length;	    
	    		var k = 0;
	    		var h = 0;
	    		for(var j = 0; j < colLen; j++) {
	    			var cm = colModel[j];
	    			if(cm.hidden && hidden != true) {
	    				if(k > 0 && cts[i - 1][k - 1].colTo == j) {
	    				    cts[i - 1][k - 1].colTo = k;
	    				}
	    				h ++;
	    				continue;	    				
	    			}
	    			var tcts = titleSheets[i][j];	   
	    			if(tcts.rowIndex != i) {
	    				continue;
	    			}
	    			if(pcts != null && pcts.caption === tcts.caption && tcts.isBand && pcts.isBand) {
	    				pcts.colspan ++;
	    				pcts.colTo++;
	    				continue;
	    			} else {
	    				cts[i - 1][k] = {isBand:tcts.isBand, caption:tcts.caption, text:tcts.caption.replace(/<[^<>]+>/g,""), colspan:tcts.colspan, rowspan:tcts.rowspan, name:cm.name, colFrom:j - h + xh, colTo:j - h + xh,s:"h"};
	    				cts[i - 1][k].colspan = 1;
	    			}
	    			pcts = cts[i - 1][k];
	    			k++;
	    		}
	    	}
	    	if(numberRow == true && this.getOption().rownumbers) {
	    		cts[0].splice(0,0,{text:this.numberCaption, colspan:1, rowspan:rowLen-1, name:"rn",colFrom:0,colTo:0,s:"h"});
	    	}
	    	return cts;
	    },
	    /**
	     * 执行焦点事件.
	     * @param ev 事件对象
	     */
	    doFocus:function(ev) {
	    	this.base();
	    	if(this.editObject != null && this.editObject.focus 
	    			|| this.scrollBar.focus) return;
	    	var cNode = null;
	    	if(this.curCell != null) {
	    	    cNode = this.curCell.parentNode._node;
	    	}
	    	if(cNode != null) {
	    		this.post();
	    		this.dataSet.select(cNode);
	    		
	    		this.colIndex = this.curColIndex;
	    		if(this.colIndex == this._colOrder["@INDEX"]) {
	    			this.colIndex = 2;
	    		}
	    		if(this.colIndex < this.beginIndex || this.colIndex > this.selRect.endColIndex 
	    				|| cNode.getIndex() < this.selRect.beginRowNode.getIndex()
	    				    || cNode.getIndex() > this.selRect.endRowNode.getIndex()) {
		    		this.selRect.beginColIndex = this.colIndex;
		    		this.selRect.endColIndex = this.colIndex;
		    		this.selRect.beginRowNode = cNode;
		    		this.selRect.endRowNode = cNode;
	    		}
	    		//获得焦点时onClick事件会在doSelect中会执行，此处不用执行
//	    		if(this.hasSelect) {
//	    			if(typeof this.onSelect == "function") {
//			    		try {
//			    			this.focusSelect = true;
//			    			//执行选择事件.		    			
//			    		    this.onSelect(this.dataSet.getCurNode(), this.getFieldName());
//			    		    
//			    		} catch(e) {
//			    			this.logInfo("[onSelect]ERR:" + e.message);
//			    		}
//			    	}
//	    			this.trigger("onCellSelect",[this.getPKeyName(),this.colIndex,this,ev]);
//	    			//单元格单击事件
//			    	if(typeof this.onClick == "function") {
//			    		try {
//			    			this.focusClick = true;
//			    			//执行选择事件.		    			
//			    		    this.onClick(this.dataSet.getCurNode(), this.getFieldName());			    		    
//			    		} catch(e) {
//			    			this.logInfo("[onClick]ERR:" + e.message);
//			    		}
//			    	}
//			    	this.trigger("onCellSelect",[this.getPKeyName(),this.colIndex,this,ev]);
//	    		}
	    	}
	    	if(this.curCell == null) {
	    		if(this.inputFocus && this.editObject != null) {
	    			this.post();
	    		}
	    	    this.refresh();
	    	}
	    	this.cellMouseDown = false;
	    },
	    /**
	     * 执行失去焦点事件.
	     * @param ev 事件对象
	     */
	    doBlur:function(ev) {
	    	//刷新
	    	if(this.inputFocus == true) {
	    		if(this.editObject != null && typeof this.editObject.getPopState == "function" && this.editObject.getPopState() === true) {
	    		    return false;
	    		}
	    	}
	    	if(this.popMenu.hasSelect 
	    		|| this.isNotEmpty(this.filterWin) && this.filterWin.hasSelect) return;	
	    	this.base();
	    	this.post();
	    	this.popMenu.setBlur();
	    	if(this.calendar != null) {
	    	    this.calendar.setBlur();
	    	}	    	
	    	this.focus = false;
	    	this.refresh();
	    	return true;
	    },
	    /**
	     * 过滤窗口初始化.
	     * @param {string} fieldName 字段
	     * @param {json} 全部选项
	     * @param {json} 选择的选项 
	     */
	    _initFilterListBox:function(fieldName, filterList, selFilterList) {
	    	if(this.pfilter.isShow()) {
	    		this.pfilter.hide();
	    	} else {
	    		if(this.pfilter.getFilterName() !== fieldName) {
	    			this.pfilter.setFilterName(fieldName);
	    			this.pfilter.clearFilter();
	    		}
	    		var oRect = this.sortTables[fieldName].getBoundingClientRect();
	    		var left = oRect.left - 230;
	    		if(left < 0) {
	    			left = 0;
	    		}
	    		var scrrect = this.getScrollXY();
	    		if(this.pfilter.getHeight() > this._getBodyHeight()) {
	    			this.pfilter.setHeight(this._getBodyHeight());
	    		}
	    		this.pfilter.execute(scrrect.top + oRect.top + 12, scrrect.left + left + 16, filterList, selFilterList);
    		}
	    },
	    /**
	     * 执行排序事件.
	     * @param colIndex 列序号
	     * @param sortState 排序类型
	     */
	    doSortAndFilter:function(colIndex, sortState) {
	    	var cm = this._getColModel(colIndex);
	    	var fieldName = cm.name;
	    	if(this.getOption().filter) {
	    		//处理筛选状态	 
	    	    var _this = this;	 
	    	    if(this.inputFocus) {
	    	    	if(typeof this.editObject.doBlur == "function") {
	    	    	    this.editObject.doBlur();
	    	        }
	    	    }
	    	    var tfi = this.dataSet.topFilterItem;
	    	    if(tfi == null || tfi.fieldName !== fieldName) {
	    	    	this.dataSet.selectFilterList = {};
			    	this.dataSet.collectFilter(fieldName, function() {
			    		_this._initFilterListBox(fieldName, 
			    				_this.dataSet.filterList[fieldName], 
			    				   _this.dataSet.selectFilterList);
			    	});
		    	} else {
		    		_this._initFilterListBox(fieldName, tfi.all, tfi.sel);
		    	}
	    	} else if(this.getOption().sort !== false){
		    	var _this = this;
		    	var ss = sortState;
		    	if(sortState == "none") {
		    		ss = "up";
		    	} else if(sortState == "up") {
		    		ss = "down";
		    	} else {
		    		ss = "none";
		    	}
		    	this.setSort(fieldName, ss);
	    	}	    	
	    },
	    /**
	     * 定位到单元格.
	     */
	    locateCell:function(rowId, fieldName) {
	    	var hasFount = false;
	    	for(var j = 1; j < this.colCount; j++) {
	    		var cm = this.option["colModels"][j - 1];
	    		if(!cm.hidden && cm.name == fieldName) {
	    			this.colIndex = j + this._colIndexDeff();
	    			hasFount = true;
	    			break;
	    		}
	    	}
	    	this.selRect.beginColIndex = this.colIndex;
	    	this.selRect.endColIndex = this.selRect.beginColIndex;
	    	this.refresh();	 
	    	return hasFount;   	
	    },
	    /**
	     * 异步定位.
	     */
	    _asynLocate:function(fieldNameJson, starNode, endNode, limit, text, full, callBack) {
	    	this.logInfo("_asynLocate:" + starNode.recNo);
	    	var colModel = this.option.colModels;
	    	var hf = true;
	    	var i = 0;
	    	var fieldName = "";
	    	var colIndex = this.colIndex - this._colIndexDeff();
	    	if(this._locateFieldName == null) {
	    		this._locateFieldName = this.getFieldName();
	    	}	    	
	    	//循环定位.
	    	while(!this.dataSet.isEof() && hf && i < limit 
	    			&& (endNode == null || this.dataSet.getIndex() < endNode.getIndex())) {
	    		var len = colModel.length;
	    		for(var j = colIndex; j < len; j++) {
	    			var fn = colModel[j].name;
	    			//如果传入数组， 不存在的，就不定位
	    			if(fieldNameJson != null && fieldNameJson[fn] == null) continue;
	    			//增加绝对定位，全部定位
	    			var dv = this.dataSet.getDisplay(fn);
		    		if(!colModel[j].hidden && (full && dv == text || !full && (dv + "").indexOf(text) >= 0)) {
		    			hf = false;
		    			fieldName = colModel[j].name;
		    			break;
		    		}
	    		}
	    		if(hf) {
//		    		if(this.treeGrid != false && !this.dataSet.isExpand()) {
//		    			this.dataSet.expand();
//		    		}
		    		i++;
		    		colIndex = 0;
		    		this.dataSet.next(true);		    		
	    		}
	    	}
	    	if(!this.dataSet.isEof() && hf && (endNode == null || this.dataSet.getIndex() < endNode.getIndex())) {
		    	//如果还没有处理结束，则异步再调用自己.
		    	this.colIndex = 1 + this._colIndexDeff();
		    	this._asynRun(function(){this._asynLocate(fieldNameJson, starNode, endNode, limit, text, full, callBack);},10);
	    	} else if(this.dataSet.isEof() && hf && (endNode == null || this.dataSet.getIndex() < endNode.getIndex())) {
	    		//从头找
	    		this.dataSet.first();
	    		this.colIndex = 1 + this._colIndexDeff();
	    		var fn = colModel[0].name;
    			//增加绝对定位，全部定位
    			var dv = this.dataSet.getDisplay(fn);
	    		if(!colModel[0].hidden && (full && dv == text || !full && (dv + "").indexOf(text) >= 0)) {
	    			hf = false;
	    			fieldName = colModel[0].name;
	    		}
	    		if(hf) {
		    	    this._asynRun(function(){this._asynLocate(fieldNameJson, this.dataSet.getCurNode(), starNode, limit, text, full, callBack); },10);
	    		} else {
	    			if(typeof callBack == "function") {
		    			callBack(hf==false);
		    		}
	    		}
		    } else {
	    		if(hf && endNode != null) {
	    			this.dataSet.select(endNode);
	    		} else if(hf == false) {
	    			this.locateCell(null, fieldName);
	    			this.dataSet.expandToNode(this.dataSet.getCurNode());
	    		} else {
	    			this.locateCell(null, this._locateFieldName);
	    		}
	    		this._locateFieldName = null
	    		if(typeof callBack == "function") {
	    			callBack(hf==false);
	    		}
		    }
	    	
	    },

	    /**
	     * 执行定位事件.
	     * @param fieldName 字段
	     * @param text 字符串
	     * @param full 是否全匹配
	     * @param checkCrt 是否检查当前行.
	     * @param callBack 回调函数
	     */
	    locate:function(fieldName, text, full, checkCrt, callBack) {
	    	if(typeof checkCrt == "function") {
	    		callBack = checkCrt;
	    		checkCrt = false;
	    	}
	    	var full = this.getBooleanValue(full, false);
	    	var hasFound = true;
	    	text = this.trim(text + "");
	        if(fieldName == "@ALL" || this.isArray(fieldName)) {
	        	this.beginUpdate();
	        	var _this = this;
	        	full = this.getBooleanValue(full, false);
	        	var fieldNameJson = {};
	        	if(this.isArray(fieldName)) {
	        		for(var i = 0, len = fieldName.length; i < len; i++) {
	        		    fieldNameJson[fieldName[i]] = 1;
	        	    }
	        	} else {
	        		fieldNameJson = null;
	        	}
	        	this._asynLocate(fieldNameJson, this.dataSet.getCurNode(), null, 50, text, full, function(rs) {
	        		_this.endUpdate();
	        		if(rs) {
	        			_this.refresh();
	        			_this.scrollToFocus();
	        		}	        		
	        		if(typeof callBack == "function") {
		        		callBack(rs);
		        	}
	        		_this = null;
	        	});
	        } else {
	        	hasFound = this.dataSet.locate(fieldName, text, full, checkCrt);
	        	//区域选择控制
	        	if(hasFound === true) {
					this.selRect.beginRowNode = this.dataSet.getCurNode();
					this.selRect.endRowNode = this.selRect.beginRowNode;
				}
	        	if(typeof callBack == "function") {
	        		callBack(hasFound);
	        	}
	        }
	        //定位后，刷新
	        this.refresh();
	        this.scrollToFocus();
	        return hasFound;
	    },
	    /**
	     * 清除所有数据.
	     */
	    deleteAll:function() {
	    	this.dataSet.empty(true);
	    	this.dataSet.first();
	    	this.refresh();
	    },
	    /**
	     * 判断当前是否选择
	     * @param node 节点
	     * @return 返回状态
	     */
	    isChecked:function(node) {
	    	return this.dataSet.isChecked(node);
	    },
	    isSelected:function(node) {
	    	return this.isChecked(node); 
	    },
	    
	    /**
	     * 获得保存列设置的key值
	     * @param userCode 登录用户代码
	     * @return 返回key 
	     * @author modify zxw 2014-10-31
	     */
	    getColumnSetupKey : function(userCode){
	    	var me = this, 
	    		key,
	    		csId = me.option.columnSetupId;
	    	if(!this.isEmpty(csId)){
	    		var dataField = me.getName();//me.control.attr("dataField"),
		    		urlHashCode = window.location.pathname,
		    		lc = $.ecp.ecpDataContext.getLoginContext(),
		    		logOrgId = lc && lc.getLoginOrgId();
		    	//登录单位ID
	    		if(!logOrgId){
	    			logOrgId = $.ecp.baseConfig.getLoginUnitCode();
	    			logOrgId = logOrgId || $.ecp.constants.DEFAULT_LOGINORGID;
	    		}
	    		//登录用户ID
	    		if(!this.isEmpty(urlHashCode)){
	    			urlHashCode = $.ecp.utils.getHashCode(urlHashCode);
	    		}
	    		key = logOrgId + "_" + userCode +  "_" + urlHashCode + "_columnSetup_" + dataField + "_" + csId;
	    	}
	    	return key;
	    },
	    /**
	     * 保存表格布局格式
	     * @param title 构建表头的字符串
	     */
	    saveColumnSetup : function(title){
	    	if($.ecp == null || $.ecp.baseConfig == null) return;
	    	try {
	    		var userCode = $.ecp.baseConfig.getYhdm() || $.ecp.constants.DEFAULT_USERCODE,
		    		key = this.getColumnSetupKey(userCode);
		    	if(this.notEmpty(key)){
		    		$.ecp.cacheManager.setServiceCache(userCode, key, title);
		    	}
	    	} catch(e) {
	    		this.logInfo("call saveColumnSetup error:" + e.message + e.stack);
	    	}
	    },
	    /**
	     * 获取表格布局格式
	     * @return 返回格式字符串
	     */
	    findColumnSetup : function(){
	    	var me = this, reslut;
	    	if($.ecp == null || $.ecp.baseConfig == null) return;
	    	try {	     
	    		var userCode = $.ecp.baseConfig.getYhdm() || $.ecp.constants.DEFAULT_USERCODE,
		    		key = me.getColumnSetupKey(userCode);		    	
		    	if(!this.isEmpty(key)){
		    		reslut = $.ecp.cacheManager.getServiceCache(userCode, key);
		    	}
	    	} catch(e) {
	    		me.logInfo("call findColumnSetup error:" + e.message + e.stack)
	    		//如果读取错误，返回空字符串
	    		result = "";
	    	}
	    	return reslut;
	    },
	    /**
	     * 单元格公式格式.
	     * @param keyFieldName 行定位用的字段，
	     * @param captionFieldName 行名称显示用字段
	     * @return 返回单元格表达式、名称表达式和单元格值， ｛"exp","#{VO$JE@BILLID1_1}", "caption","AAAA", "value":"1"｝
	     */
	    getCellExpObject:function(keyFieldName, captionFieldName) {	    	
	    	if(this.dataSet.getRecordCount() > 0) {
	    		var colFieldName = this.getFieldName();
	    		var cellValue = this.dataSet.getValue(keyFieldName);
	    		var expValue = this.getName() + "$" + colFieldName 
	    		    + "~~" + keyFieldName + "_" + cellValue;
	    		var expText = this.dataSet.getValue(captionFieldName) + "_" + this.dataSet.getIndex() 
	    		    + "," + this.getTitleName(this.colIndex);
	    		return {
	    			"exp":expValue,
	    			"caption":expText,
	    			"value":cellValue
	    		}
	    	} else {
	    		return null;
	    	}
	    },
	    /**
	     * 获取标题名称.
	     */
	    getTitleName:function(colIndex) {
	    	var titleSheets = this.option["titleSheets"];
	    	var caption = [];
	    	var rlen = this.titleRowCount - 1;
	    	for(var i = 1; i <= rlen; i++) {
	    		var tst = titleSheets[i][this.colIndex - 1];
	    		if(tst.rowIndex == i) {
	    		    caption[i - 1] = tst.caption;
	    		}
	    	}
	    	return caption.join("_");
	    },
	    /**
	     * 添加公式表达式.
	     * @paran colFieldName 列字段
	     * @param keyFieldName 行定位字段
	     * @param keyValue 行定位值
	     * @param expJson 表达式 {"exp":"", "caption":""};
	     */
	    addExpress:function(colFieldName, keyFieldName, keyValue, expJson) {
	    	this.dataSet.addExpress(colFieldName, keyFieldName, keyValue, expJson);
	    },
	    /**
	     * 添加公式表达式.
	     * @param keyFieldName 索引列字段
	     * @param expJson 表达式 {"exp":"", "caption":""};
	     */	    
	    addGJExpress:function(keyFieldName, expJson) {
	    	this.dataSet.addGJExpress(keyFieldName, expJson);
	    },
	    /**
	     * 执行运算.
	     * @param full true 全运算/false 增量运算
	     */
	    caculate:function(full) {
	    	this.dataSet.caculate(full);
	    },
	    /**
	     * 执行勾稽.
	     * @param full true 全运算/false 增量运算
	     */
	    caculateGJ:function(full, callBack) {
	    	return this.dataSet.caculateGJ(full, callBack);
	    },
		/**
		 * 执行勾稽.
		 * @param full true 全运算/false 增量运算
		 */
	    caculateSum:function(full) {
	    	this.dataSet.caculateSum(full);
	    },
	    /**
	     * 显示列.
	     * @param {Array}fieldAry 字段 
	     */
	    showCol:function(fieldAry) {
	    	if(typeof fieldAry == "string") {
	    		var cm = this.getColModel(fieldAry);
	    		if(cm != null) {
	    			cm.hidden = false;
	    		}
	    		cm = null;
	    	} else if(this.isArray(fieldAry)) {
	    		for(var i = 0, len = fieldAry.length; i < len; i++) {
	    			var cm = this.getColModel(fieldAry[i]);
	    			if(cm != null) {
	    				cm.hidden = false;
	    			}
	    		}
	    	}
	    	this.refresh();	    	
	    	this.listDivBox.style.width = "";
	    	if(this.getOption().shrinkToFit !== false) {
	    		this.resetColWidth();
	    		this._tmpWidth = null;
	    	    this.shrinkToFit();
	    	}
	    	if(this.getOption().suitToFit === true) {
	    		this.suitToFit();
	    	}	
	    	this.refreshVScrollBar();
	    },
	    isColHidden:function(fieldName) {
	    	var cm = this.getColModel(fieldName);
	    	return cm.hidden;
	    },
	    isColShow:function(fieldName) {
	    	return !this.isColHidden(fieldName);
	    },
		/**
		 * 隐藏列.
		 * @param {Array}fieldAry 字段 
		 */	    
	    hideCol:function(fieldAry) {
	    	if(typeof fieldAry == "string") {
	    		var cm = this.getColModel(fieldAry);
	    		if(cm != null) {
	    			cm.hidden = true;
	    		}
	    		cm = null;
	    	} else if(this.isArray(fieldAry)) {
	    		for(var i = 0, len = fieldAry.length; i < len; i++) {
	    			var cm = this.getColModel(fieldAry[i]);
	    			if(cm != null) {
	    				cm.hidden = true;
	    			}
	    		}
	    	}	    	
	    	this.listDivBox.style.width = "";
	    	if(this.getOption().shrinkToFit !== false) {
	    		this._tmpWidth = null;
	    	    this.shrinkToFit();
	    	}
	    	if(this.getOption().suitToFit === true) {
	    		this.suitToFit();
	    	}
	    	this.refresh();
	    	this.refreshVScrollBar();
	    },
	    /**
	     * 更新colNames属性.
	     */
	    _updateColNames : function(rowIndex, colIndex, newLabel) {
	    	var ol = this.option.titleSheets[rowIndex][colIndex].caption;
			var nlAry = ol.match(/(<[^<>]+>)|([^<>]+)/g);
			for(var i = nlAry.length - 1; i >= 0; i--) {
				if(nlAry[i].indexOf("<") < 0) {
					nlAry[i] = newLabel;
					break;
				}
			}
			var nl = nlAry.join("");
			this.option.titleSheets[rowIndex][colIndex].caption = nl;
			if(this.option.titleString != null) {
				for(var i = 0, len = this.colNames.length; i < len; i++) {
					if(this.colNames[i] == ol) {
						this.colNames[i] = nl;
						this.option.titleString = this.option.titleString.replace(ol, nl);
						break;
					}
				}
			}
	    },
	    /**
	     * 修改表头caption.
	     */
	    setTitleCaption : function(startColName,newLabel,level,isHtml) {
	    	this.setHeaderLabel(startColName,newLabel,level,isHtml);
	    },
	    /**
	     * 修改表头caption.
	     */
        setHeaderLabel : function(startColName,newLabel,level,isHtml){
	    	 var cm = this.getColModel(startColName);
	    	 if(cm != null) {
	    		var col = this.titleCol[cm.colIndex];
	    		if(level == 1) {
	    			this.copyDiv.appendChild(col.dom.sortDiv);
	    			this._setTdText(col, newLabel, isHtml);
	    			this._updateColNames(this.titleRowCount - 1, cm.colIndex, newLabel);
	    			col.insertBefore(col.dom.sortDiv, col.childNodes[0]);
	    			if(this.isNotEmpty(col.mainCell)) {
	    				//有冻结列
	    				var mcol = col.mainCell;
	    				if(l == level) {
	    					this._setTdText(mcol, newLabel, isHtml);
	    					mcol.insertBefore(mcol.dom.sortDiv, mcol.childNodes[0]);
		    			}
	    			}
	    			return;
	    		}
	    		var bri = col.option.bandRowIndex;
	    		var bci = col.option.bandColIndex;
	    		//循环处理所有层次的隐藏
	    		var l = 2;
	    		var cdf = 0;
	    		while(this.isNotEmpty(bri) && bri > 0 && l <= level) {
	    			if(bri == 1) {
	    				bci ++;
	    				cdf = this._colIndexDeff();
	    			}
	    			var tcol = this.gridTable.rows[bri].cells[bci + cdf];
	    			if(l == level) {
	    				this._setTdText(tcol, newLabel, isHtml);
	    				this._updateColNames(bri, bci, newLabel);
	    				//tcol.insertBefore(tcol.dom.sortDiv, tcol.childNodes[0]);
	    			}
	    			if(this.isNotEmpty(col.mainCell)) {
	    				//有冻结列
	    				var mcol = this.fzGridTable.rows[bri].cells[bci + cdf];
	    				if(l == level) {
	    					var i = mcol.childNodes.length - 1;
	    					if(i >= 0) {
	    						this._setTdText(mcol, newLabel, isHtml);
	    						//mcol.insertBefore(mcol.dom.sortDiv, mcol.childNodes[0]);
	    					}
		    			}
	    			}
	    			bri = tcol.option.bandRowIndex;
	    			bci = tcol.option.bandColIndex;
	    			l ++;
	    		}
	    	 }
		},
		/**
		 * 设置选中行.
		 * @param rowId  行id
		 * @param cellName 列名
		 * @param onselect 是否触发选中事		 
		 * @param highLight 是否高亮
		 */
		 setSelection : function(rowId, cellName, onselect, highLight){
			var hasFound = false;
			if(rowId){
				hasFound = this.locate(this.getPKeyName(),rowId,true);
				if(onselect) {
					this.trigger("onSelectRow", []);
				}
			}
			if(hasFound && cellName){
				this.locateCell(rowId,cellName);
			}
			if(hasFound) {
				this.trigger("onSelectEcpRow",[rowId, cellName, null]);
			}
		 },
		 /**
		  * 异步选择函数
		  * @name _asynCheck
		  * @ignore
		  */
		 _asynCheck:function(type, limit, node, fieldName, option, callback) {
			    this.logInfo("_asynCheck:" + type + " " + node.recNo);
			    var i = 0;
			    this.dataSet.beginUpdate();
			    var cNode = this.dataSet.curNode;
			    //设置起始节点
			    this.dataSet.select(node);
			    //循环处理所有节点 
			    while(!this.dataSet.isEof() && i < limit) {
			    	//如果层次小于等于level, 且收缩的，则展开
			    	var cop = this.dataSet.getCellOption(fieldName);
			    	if(cop.disabled !== true) {
				        switch(type) {
				        case this.dataSet.checkType.all :
				            this.dataSet.setValue(fieldName, option.editoptions.check);
				            break;
				        case this.dataSet.checkType.unall :
				        	this.dataSet.setValue(fieldName, option.editoptions.uncheck);
				        	break;
				        case this.dataSet.checkType.rever :
				        	if(this.dataSet.getValue(fieldName) === option.editoptions.uncheck) {
				        		this.dataSet.setValue(fieldName, option.editoptions.check);
							} else {
								this.dataSet.setValue(fieldName, option.editoptions.uncheck);
							}
				        	break;
				        default :
				        	this.dataSet.setValue(fieldName, option.editoptions.check);
				        }	
			    	}
			        this.dataSet.next(true);
			    	i++;
			    }
			    node = this.dataSet.curNode;
			    i = null;
			    if(!this.dataSet.isEof()) {
			    	//如果还没有处理结束，则异步再调用自己.
			    	this.dataSet.select(cNode);
			    	this.dataSet.endUpdate(false);
			    	this._asynRun(function(){this._asynCheck(type, limit, node, fieldName, option, callback); },10);
			    } else {
			    	//如果处理结束，则调用回调函数
			    	this.dataSet.select(cNode);
			    	this.dataSet.endUpdate(false);
			    	if(typeof callback == "function") {
			    		callback.apply(this);
			    	}
			    }	
		 },
		/**
		 * 全选方法.	 
		 */
		 checkAll:function(fieldName, titleState, callBack) {			 
			 if(typeof fieldName == "function") {
					callBack = fieldName;
					fieldName = "";
					titleState = true;
			 }
			 if(typeof titleState == "function") {
				 callBack = titleState;
				 titleState = true;
			 } else if(titleState == null) {
				 titleState = true;
			 }
			 var _this = this;
			 if(typeof fieldName === "string" && fieldName !== "") {
				var op = this.dataSet.getFieldOption(fieldName);
				if((op.editType === "checkBox" || op.editType === "onoff") && this.dataSet.getRecordCount() > 0) {
					this._asynCheck(this.dataSet.checkType.all, 100, this.getChildNode(0, this.dataSet.rootNode), fieldName, op, 
				    function(){
				    	_this.refresh();
				    	if(typeof callBack === "function") {				    		
				    	    callBack.apply(_this);
				    	}
				    });
				}
			 } else {
			    this.dataSet.selectAll(function(){
			    	_this.refresh();
			    	if(typeof callBack === "function") {			    		
			    	    callBack.apply(_this);
			    	}
			    });
			    if(titleState) {
			        this.setTitleChecked("@MUL", true);
			    }
			 }
		 },
		 selectAll : function(fieldName, titleState, callBack){
			 this.checkAll(fieldName, titleState, callBack);
		 },
		 /**
		  *  取消选中行.
		  */
		 cancelCheckRow:function(fieldName, titleState, callBack) {
			 if(typeof fieldName == "function") {
					callBack = fieldName;
					fieldName = "";
					titleState = true;
				}
				if(typeof titleState == "function") {
					 callBack = titleState;
					 titleState = true;
				 } else if(titleState == null) {
					 titleState = true;
				 }
				if(typeof fieldName === "string" && fieldName !== "") {				
					var op = this.dataSet.getFieldOption(fieldName);
					if((op.editType === "checkBox" || op.editType == "onoff") && this.dataSet.getRecordCount() > 0) {
						this._asynCheck(this.dataSet.checkType.unall, 100, this.getChildNode(0, this.dataSet.rootNode), fieldName, op, callBack);
					}
				 } else {
					 this.dataSet.unCheckAll(callBack);
					 if(titleState) {
					     this.setTitleChecked("@MUL", false);
					 }
				 }
		 }, 
		cancelSelectRow	: function(fieldName, titleState, callBack){
			this.cancelCheckRow(fieldName, titleState, callBack);
		},
		/**
		 * 设置标题状态.
		 * @name setTitleChecked
		 * @param fieldName 字段名称，复选择列为 @MUL
		 * @param val 状态 true/false
		 */
		setTitleChecked:function(fieldName, val) {
			if(typeof fieldName == "boolean") {
				val = fieldName;
				fieldName = "@MUL";
			} else if(fieldName === "") {
				fieldName = "@MUL";
			}
			if(this._checkBoxs != null && this._checkBoxs[fieldName] != null) {
			    this._checkBoxs[fieldName].setCheck(val);
			}
		},
		/**
		 * 表格反选
		 */
		reverCheckRow:function(fieldName, callBack) {
			if(typeof fieldName === "string" && fieldName !== "") {				
				var op = this.dataSet.getFieldOption(fieldName);
				if((op.editType === "checkBox" || op.editType == "onoff") && this.dataSet.getRecordCount() > 0) {
					this._asynCheck(this.dataSet.checkType.rever, 100, this.getChildNode(0, this.dataSet.rootNode), fieldName, op, callBack);
				}
			 } else {			
			    this.dataSet.reverCheckAll(callBack);
			 }
		},
		reverSelectRow : function(fieldName, callBack){
			this.reverCheckRow(fieldName, callBack);
		},
		/**
		 * 表格全选/取消全选方法
	     * @param status   true为全选，false为取消全选 
		 */
		multiCheckRows:function(status, fieldName, callBack) {
			if(status){
				this.checkAll(fieldName, callBack);
				//this.setTitleChecked("@MUL", true);
			}else{
				this.unCheckAll(fieldName, callBack);
				//this.setTitleChecked("@MUL", false);
			}
		},
		multiSelectRows	: function(status, fieldName, callBack){
			this.multiCheckRows(status, fieldName, callBack)
		},
		/**
		 * 执行过滤数据.
		 * @param {string} cellName  列名
		 * @param {string} operator 操作	 
		 * @param {string} data 过滤值
		 */
		 filterGridData : function(cellName, operator, data, callBack){
			//true 执行过滤
		    var me = this;
			this.dataSet.addFilterText(cellName, data,  function() {
				me.first();
				if(typeof callBack == "function") {
					callBack();
				}
				me = null;
			});			
		 },
		 /**
		  *  重置列宽度方法.
	      * @param cellname  列关键字
	      * @param newWidth 新宽度
		  */
		 resizeColWidth : function(cellname, newWidth){
			this.getColModel(cellname).width = newWidth;
		 },
		 /**
		  * 根据rowId,从数据模型中取出数据.
	      * @param rowId  列名 
		  */
		 getDataByRowId : function(rowId){	
			 var cn = this.dataSet.curNode;
			 this.dataSet.beginUpdate();
			 this.locate(this.getPKeyName(),rowId,true);
			 var cd = this.dataSet.curNode.data;
			 this.dataSet.select(cn);
			 this.dataSet.endUpdate(false);
			 cn = null;
			 return cd;
		 },
		 /**
		  * 修改行数据与样式
	      * @param rowId  列名 
	      * @param data  数据
	      * @param clazz  样式 
		  */
		 setRowData : function(rowId,data,clazz){
			//旧的接口，不用了
		},
		/**
		 * 修改行数据与样式
	     * @param rowId  列名 
	     * @param data  数据
	     * @param clazz  样式 
		 */
		updateEcpRowData : function(rowId,data,clazz){
			this.setRowData.apply(this, arguments);
		},
		/**
		 * 从数据模型中取出数据更新表格行数据
	     * @param rowId  
		 */
		updateRowData : function(rowId){
			this.refresh();
		},
		/**
		 * 冻结列
	     * @param cellName  列名 
		 */
		frozenCol : function(cellName){
			if (cellName){
				this.getColModel(cellName).frozen = true;
				this.refresh();
			}

		},
		/**
		 * 设置列布局，居中、居左、居右
	     * @param cellName  列名 
	     * @param align  布局（left/right/center）	
		 */
		setColAlign : function(cellName,align){
			if (cellName){
				this.dataSet.getFieldOption(cellName).align = align;
				this.refresh();
			}
		},
		/**
		 * 根据序号获取gid.
		 */
		getGidByIndex : function(index){
			this.dataSet.locate("@INDEX",index,true);
			return this.dataSet.getCurNode().data[this.getPKeyName()];

		},
		/**
		 * 重新渲染表格.
		 */
		reloadGrid : function(option){
			
		},
		/**
		 * 保存单元格
		 */		 
		saveCell : function(iRow,iCol){
		},
		/**
		 * 修改单元格值
		 */		 
		setCell : function(rowid,colname,data,clazz,properties,forceup){
				
		},
		/**
		 * 设置合计列
		 */		 
		setAmountCell : function(num,fn,format,isExtend){
			
		},
//		/**
//		 * 设置合计列
//		 */		 
//		setAmount : function(num,fn,format,isExtend){
//			
//		},
		/**
		 * 获取合计行数据
		 */		 
		getAmount : function(cellName){
					
		},		
		/**
		 * 获取合计列数据,合计行有多行时用此方法
		 */		 
		getAmountCell : function(num,cellName){
					
		},
		/**
		 * 表格筛选方法
		 */		 
		searchGrid : function(){
		},
		/**
		 * 获取表头高度.
		 * @return {number} 返回表头高度
		 */
		getTitleHeight:function() {
			return this.titleHeight;
		},
		/**
		 * 隐藏表头.
		 * @see qzz#hideGridHeader
		 */
		hideTitle:function() {
			this.hideGridHeader();	
		},
		/**
		 * 隐藏表头.
		 * @see qzz#hideGridHeader
		 */
		hideGridHeader:function() {
			for(var i = this.titleRowCount - 1; i > 0; i--) {
				this.gridTable.rows[i].style.display = "none";
				this.fzGridTable.rows[i].style.display = "none";
			}
			this.titleIsHide = true;
			this.initGrid();
			this.dataSet.first();
	    	this.topNode = this.dataSet.getCurNode();
	    	this.refresh();
		},
		/**
		 * 显示表头.
		 * @see qzz#hideGridHeader
		 */
		showTitle:function() {
			this.showGridHeader();
		},
		/**
		 * 显示表头.
		 */
		showGridHeader:function() {
			for(var i = this.titleRowCount; i > 0; i--) {
				this.gridTable.rows[i].style.display = "";
				this.fzGridTable.rows[i].style.display = "";
			}
			this.titleIsHide = false;
			this.initGrid();
			this.dataSet.first();
	    	this.topNode = this.dataSet.getCurNode();
	    	this.refresh();
		},
		/**
		 * 隐藏合计行
		 */ 
		hideGridFooterrow : function(){
			this.getOption().footerrow = false;
			this.refresh();
		},
		/**
		 * 显示合计行
		 */
		showGridFooterrow : function(){
			this.getOption().footerrow = true;
			this.refresh();
		},
		/**
	     * 设置合计行
	     * @param {string} cellName: 单元格名
	     * @param {function|object} fn(data, name): 执行函数，其中参数为data(dataField对应的数据),name为传入的cellName
	     * @param {string} format : 是否根据单元格进行format
	     */
	    setAmount: function(cellName, fn, format){
			var value;
			if(typeof fn  == "function"){
				value = fn();
			}else{
				value = fn;
			}
			if(cellName == "rn"){
				this.summaryText = value;				
			}else{
				this.dataSet.setSummary(cellName, value);
			}
			this.refresh();			
		},
		/**
		 * 返回当前页面数据.
		 * @name getPageData
		 * @example
		 *    var datas = grid.getPageData();
		 * @return {Array} datas 返回数据数组
		 */
		getPageData:function() {
			var datas = [];
			if(this.dataSet.getRecordCount() > 0) {
				var cN = this.dataSet.getCurNode();
				this.dataSet.beginUpdate();
				this.dataSet.first();
				while(!this.dataSet.isEof()) {
					datas.push($.extend({}, this.dataSet.getCurNode().data));
					this.dataSet.next(true);
				}
				this.dataSet.select(cN);
				this.dataSet.endUpdate(false);
			}
			return datas;
		},
		/**
		 * 返回指定范围数据
		 * @param {Object | String} range 范围 all：全部|current:当前页|{begin:1,end:2}:指定页
		 * @param display 是否取名称  true:取名称|false:取id 
		 * @param escape 是否转义
		 * @param {Function} callback 回调函数
		 * @author yinshanpeng@ygsoft.com
		 * @date 2014.11.14
		 */ 
		getRangeData:function(range, display, escape, callback) {
			if(typeof display == "function") {
				callback = display;
				display = false;
				escape = false;
			} else if(typeof escape == "function") {
				callback = escape;
				escape = false;
			}
			if(display == null) {
				display = false;
			}
			if(!this.isNotEmpty(range) || !$.isFunction(callback)) {
				return ;
			}
			//是否打印(预览)当前(全部)页，默认否
			var isCur = isAll = false ;
			
			var me = this ,
				opt = me.option ,
				params ,datas ,b ,e ;
			
			if(typeof(range) === "object") {
				b = +range.begin;
				e = +range.end;
				//输入的开始页大于结束页时，打印(预览)当前页
				isCur = b > e ? true : false;
				!isCur && (isAll = ((e+1) - b) === me.getOption().pageCount ? true : false); 
			}else if (typeof(range) === "string") {
				if(range === "current" || !opt.pager) {
					isCur = true;
				} else if (opt.pager && range === "all") {
					isAll = true;
				}
			}else if (opt.pager === false) {
				isCur = true;
			}
			!isCur && (me._lockValue = true);
			
			//intercept datas
			//通过标识，决定是否截取数据，而不让数据直接渲染至表格
			me._icpData = function(datas) {
				me._lockValue = false;
				if(display) {
					var dds = [];
					var ds = me.dataSet;
					var cn = ds.getCurNode();
					
					me.dataSet._tmpData = datas;
					for(var key in me.dataSet.transState) {
						me.dataSet.transState[key].transed = false;
					}
					
					var rd = cn.data;
					for(var i = 0, len = datas.length; i < len; i++) {
						var cd = datas[i];
						var dcd = {};
						if(cd != null) {
							cn.data = cd;						
							for(var key in cd) {
								var cv = cd[key];
								var cvt = typeof cv;
								if(cvt == "object") {
									var cdcd = {};
									dcd[key] = cdcd;
									for(var ckey in cv) {
										var ccv = cv[ckey];
										ccv = ds.getDisplay(key + "." + ckey, ccv, cn, null, escape);
										cdcd[ckey] = ccv;
									}
								} else {
									cv = ds.getDisplay(key, cv, cn, null, escape);
									dcd[key] = cv;
								}
							}
						}
						cd = null;
						dds.push(dcd);
					}					
					me.dataSet._tmpData = null;
					
					cn.data = rd;
					ds = null;
					cn = null;
					rd = null;
					callback.call({} ,dds);
				} else {				
				    callback.call({} ,datas);
				}
				me._icpData = null;
			}
			
			//处理服务端分页
			//操作指定范围内数据（非全部、当前）
			if(!isCur && !isAll && opt.pager === true) {
				params = me._crPrms(b ,e);
			    me._loadSerData(me.getOption().pageCount ,params.ps ,params.idx);
			 //如果操作当前页，则不再请求数据
			}else if(isCur) {
				//me._icpData = null;
				me._icpData(me.getPageData());
				//callback.call({} ,me.getPageData());
			 //操作全部数据
			}else if(isAll) {
				params = me._crPrms();
				me._loadSerData(me.getOption().pageCount ,params.ps ,params.idx);		
			}
		 },
		/**
		 * 取服务端数据(主动激活onPageChanged事件,拦截数据)
		 * @ignore
		 * @author yinshanpeng@ygsoft.com
		 * @date 2014.11.14
		 */
		_loadSerData : function(pc ,ps ,idx) {
			var me = this ;
			//重新计算总数
			var cc = this.dataSet.getRecordChanged();
			if(this.getOption().pager === true && cc !== 0) {
	        	var oldc = this.pageObj.getTotalCount();
    			this.pageObj.setTotalCount(oldc-cc, false);
	        }
			if (typeof(me.onPageChanged) == "function") {
    			try {
    				me.onPageChanged(pc, ps, idx);
    			} catch(e) {
    				me.logInfo("[onPageChanged] event error!" + e.message + e.stack);
    			}
    		}else if (me.hasbind("onPageChanged")) {
    			me.trigger("onPageChanged", [pc, ps, idx]);
    		}
		},
		/**
		 * 构造合理的分页参数，旨在减少请求数据次数
		 * @ignore
		 * @param {Number} b 开始页
		 * @param {Number} e 结束页
		 * @return {Object} 参数对象
		 * @author yinshanpeng@ygsoft.com
		 * @date 2014.11.15
		 */
		_crPrms : function() {
			 var params = {ps:0 ,idx:1} ,
			 	 me = this ;
			 	 
			 if(arguments.length === 0) {				 
				 params.ps = me.pageObj.getTotalCount();
			 }else if(arguments.length === 2){
				 	 //开始页
				 var b = arguments[0] ,
				 	 //结束页
				 	 e = arguments[1] ,
				 	 //打印、预览的页数
				 	 ct = e - b + 1 ;
				     
				b += "";
				while(b.length < 5) {
					b = 0 + b;
				}
					
				params.ps = me.pageObj.getOption().pageSize;
				//example : -1200003 第3页开始，打印、预览12页(高低位算法)
				params.idx = -(+(ct + b));
			 }
			return params;
		 },
		/**
		 * 不可用属性设置.
		 * @name disable
		 */
		disable:function() {
			this.base();
			this.setReadOnly(true);
		}, 
	    /**
	     * 开始刷新
	     */
	    beginUpdate:function() {
	    	this.base();
	    	this.dataSet.beginUpdate();
	    },
	    /**
	     * 结束刷新
	     */
	    endUpdate:function(state) {
	    	this.dataSet.endUpdate(state);
	    	this.base();	    	
	    },
		/**
		 * 可用属性设置.
		 * @name enable
		 */
		enable:function() {
			this.base();
			this.setReadOnly(false);
		}, 
		/**
		 * 返回格式化后的数据.
		 */
		getDisplayData:function(type, callBack) {
			if(typeof type === "function") {
				callBack = type;
				type = "array";
			}
			var fnAry = [];
			for(var i = 0, len = this.option.colModels.length; i < len; i++) {
				cm = this.option.colModels[i];
				if(!cm.hidden) {
					fnAry.push(cm.name);
				}				
			}
			this.dataSet.getDisplayData(fnAry, type, callBack);
		},
		/**
		 * 获得changedSet.
		 */
		getChangeSet:function(single) {
			 //获取变量集时先post一下.
			 this.post();
			 if(single !== true && this.getOption().cacheChangeSet === true) {
				 var re = [];
				 for(var key in this._cacheChangeSet) {
					 var ccs = this._cacheChangeSet[key];
					 if(typeof ccs !== "function") {
						 if(key === this._cacheKey) {
							 ccs = this.dataSet.getChangeSet();
						 }
						 re = re.concat(ccs);
					 }					 
				 }
				 return re;
			 } else {			
			     return this.dataSet.getChangeSet();
			 }
		},
		/**
		 * 获得变更集.
		 */
		getEcpChangeSet:function(single) {
			//获取变量集时先post一下.
		    this.post();
			if(single !== true && this.getOption().cacheChangeSet === true) {
				//ecp结构
				 var re = {
						    list:[],
						    deleteList:[]
				          };
				 for(var key in this._cacheEcpChangeSet) {
					 var ccs = this._cacheEcpChangeSet[key];
					 if(typeof ccs !== "function") {						 
						 if(key === this._cacheKey) {
							 ccs = this.dataSet.getEcpChangeSet();
						 }					 
						 re.list = re.list.concat(ccs.list);
						 re.deleteList = re.deleteList.concat(ccs.deleteList);
					 }
				 }
				 return re;
			 } else {	
			     return this.dataSet.getEcpChangeSet();
			 }
		},
		getRecordCount:function(){
			return this.dataSet.getRecordCount();
		},
        /**
         * 合并日志.
         */
        mergeChangeLog:function(ids) {
        	if(this.getOption().cacheChangeSet === true) {
        		this._cacheChangeSet = {};
        		this._cacheEcpChangeSet = {};
        	}
        	this.dataSet.mergeChangeLog(ids);
        },
		/**
	     * 获取滚动条是否隐藏.
	     * @return 返回
	     */
	    getHScrollHide:function() {
	    	var sw = this._getNumberValue(this.listDiv.style.width);//this.getOption().width;
	    	//if(this.scrollBar.visible) {
	    	//	sw -= this.scrollBar.getWidth();
	    	//}
	    	
	        //添加空判断
	    	return this._getNumberValue(this.gridTable.style.width) < sw;
	    },
	    doContainerShow:function() {
	    	if(this.getOption().shrinkToFit !== false) {
	    		this.shrinkToFit();
	        }
	    	if(this.getOption().suitToFit === true) {
	    		this.suitToFit();
	        }	    	
	    	this._suitTitleHeight();	
	    	//显示完成后，就不需要再处理了
	    	if(this.showHandle != null) {
	    	    clearInterval(this.showHandle);
	    	    this.showHandle = null;
	    	}
	    },
	    getEcpType: function(){
	       return  this.className;	
	    },
	    setPageByRowId:function() {
	    	//兼容不报错用
	    },
	    getDisplayFirstColModel:function() {
	    	//兼容不报错用
	    },
	    /**
	     * 兼容旧表格.
	     */
	    setEmptyRowData:function() {
	    	
	    },
	    setFiltered:function(filtered, callBack) {
	    	var _this = this;
	    	this.dataSet.setFiltered(filtered, function() {
	    		_this.first();
	    		if(typeof callBack == "function") {
	    			callBack();
	    		}
	    	});
	    },
	    getTotalValue:function(fieldName) {
	    	if(this.getOption().totalRever === true) {
	    		return this.dataSet.getSubtotalValue(fieldName);
	    	} else {
	    	    return this.dataSet.getTotalValue(fieldName);
	    	}
	    },
	    getSubtotalValue:function(fieldName){
	    	if(this.getOption().totalRever === true) {
	    		return this.dataSet.getTotalValue(fieldName);
	    	} else {
	    		return this.dataSet.getSubtotalValue(fieldName);
	    	}
	    },
	    setTotalValue:function(fieldName, value) {
	    	if(this.getOption().totalRever === true) {
	    		this.dataSet.setSubtotalValue(fieldName, value);
	    	} else {
	    	    this.dataSet.setTotalValue(fieldName, value);
	    	}
	    },
	    setSubtotalValue:function(fieldName, value) {
	    	if(this.getOption().totalRever === true) {
	    		this.dataSet.setTotalValue(fieldName, value);
	    	} else {
	    		this.dataSet.setSubtotalValue(fieldName, value);
	    	}
	    },
	    /**
	     * 循环选择节点.
	     */
	    eachChecked:function(node, eachFunc, desc, callBack) {
	    	 var nt = typeof node;
			 var dt = typeof desc;
			 if(nt === "function") {
				 var et = typeof eachFunc;
				 if(et === "function") {
					 desc = false;					 
					 callBack = eachFunc;
				 } else if(et === "boolean") {
					 if(dt === "function") {
						 callBack = desc;
					 }
					 desc = eachFunc;
				 }
				 eachFunc = node;
				 node = this.dataSet.rootNode;
			 } else if(nt == "object") {				 
				 if(dt === "function") {
					 callBack = desc;
					 desc = false;
				 }				 
			 }
		     if(desc) {
		    	 //获得node的最后一个子节点
		    	 var cNode = this.dataSet.lastNode(node);
		     } else {
		    	 cNode = node;
		     }
		     var _this = this;
			 this.dataSet.eachChecked(node, eachFunc, desc, function(){
			    if(_this.multiSelect === true && this.getRecordCount() == 0) {
		    		_this.setTitleChecked("@MUL", false);
		    	}
				_this.refresh();
			    if(typeof callBack === "function") {
			    	callBack();
			    }
			});	
	    },
	    /**
	     * 循环数据.
	     * 内部自动带有刷新
	     */
	    each:function(node, eachFunc, desc, callBack) {
	    	 var nt = typeof node;
			 var dt = typeof desc;
			 if(nt === "function") {
				 var et = typeof eachFunc;
				 if(et === "function") {
					 desc = false;					 
					 callBack = eachFunc;
				 } else if(et === "boolean") {
					 if(dt === "function") {
						 callBack = desc;
					 }
					 desc = eachFunc;
				 }
				 eachFunc = node;
				 node = this.dataSet.rootNode;
			 } else if(nt == "object") {				 
				 if(dt === "function") {
					 callBack = desc;
					 desc = false;
				 }				 
			 }
		     if(desc) {
		    	 //获得node的最后一个子节点
		    	 var cNode = this.dataSet.lastNode(node);
		     } else {
		    	 cNode = node;
		     }
		     var _this = this;
			 this.dataSet.each(node, eachFunc, desc, function(){
				if(_this.multiSelect === true && this.getRecordCount() == 0) {
			    	_this.setTitleChecked("@MUL", false);
			    }
				_this.refresh();
			    if(typeof callBack === "function") {
			    	callBack.apply(_this);
			    }
			});
		 },
		 //返回行序号.
		 getIndex:function() {
			 return this.dataSet.getIndex();
		 },
		 /**
		  * 表头结构转换成数据包.
		  */
		 colNamesToColDatas:function(cms, cns) {
			var rowLen = cns.length;
			//先转换成二维数组.
			var cnsAry = [];
			if(rowLen > 0) {
				if(typeof cns[0] == "string") {
					cns = [cns];
					rowLen = 1;
				}
				for(var i = 0, ilen = cns.length; i < ilen; i++) {
					var rcns = cns[i];
					var cindex = 0;
					var crow = [];
					for(var j = 0, jlen = rcns.length; j < jlen; j++) {
						var ccns = rcns[j];
						var cname = ccns;
						if(typeof cname !== "string") {
							cname = cname.caption;
						}
						//startIndex为0时,cindex的赋值判断等价于: cindex = 0 || undefined
						//即多表头若从第一个表头开始,会出现数据错乱(cindex=undefined), 所以需要先判断下标为0的情况 --liyishan 2017/6/10
						if(ccns.startIndex !== 0){
							cindex = ccns.startIndex || ccns.startindex;
						}
						var ccolspan = ccns.colSpan || ccns.colspan || 1;
						if(cindex != null) {
							crow[cindex] = cname;
							for(var ci = cindex + 1; ci < cindex + ccolspan; ci++) {
								crow[ci] = cname;
							}
						} else {
							crow[j] = cname;
						}
					}
					cnsAry.push(crow);
				}
			}
			var splitChar = "◆";
			var headVals = [];
			//合成数据包
			for(var i = 0, ilen = cms.length; i < ilen; i++) {
				var hvas = {};
				var rowName = [], rowCaption = [];
				for(var r = 0; r < rowLen; r++) {
					var curName = cnsAry[r][i] || "";
					rowName.push(curName);
					if(curName !== "") {
						rowCaption.push(curName);
					}
				}
				//hvas.index = i;
				hvas.rowNames = rowName;
				hvas.rowName = rowCaption.join(splitChar);
				hvas.colModel = cms[i];
				hvas.display = cms[i].hidden !== true;
				hvas.frozen = cms[i].frozen === true;
				hvas.groups = cms[i].groups === true;
				headVals.push(hvas);
			}
			return headVals;
		 },
		 /**
		  * 表头数据包转换成表头结构.
		  */
		 colDatasToColNames:function(headVals) {
			var cms = [], cns=[], pName = [], pIndex = [], pColspan = [];
			//先排序，把固定列上符
			var sortVals = [];
			for(var i = 0; i < 2; i++) {
				for(var j = 0, jlen = headVals.length; j < jlen; j++) {
					var chv = headVals[j];
					if(i == 0) {
						if(chv.frozen === true) {
							sortVals.push(chv);
						}
					} else {
						if(chv.frozen !== true) {
							sortVals.push(chv);
						}
					}
				}
			}
			headVals = sortVals;
			//转换
			for(var i = 0, ilen = headVals.length; i < ilen; i++) {
				var hvas = headVals[i];
				var cm = hvas.colModel;
				cm.hidden = hvas.display === false;
				cm.frozen = hvas.frozen === true;
				cm.groups = hvas.groups === true;
				cms.push(cm);
				var rowNames = hvas.rowNames;
				for(var r = 0, rlen = rowNames.length; r < rlen; r++) {
					if(cns[r] == null) {
						cns[r] = [];
						pIndex[r] = -1;
						pName[r] = "";
					}					
					var cName = rowNames[r];
					if(r < rlen - 1) {
						if(pName[r] !== cName) {
							if(pName[r] !== "") {
								cns[r].push({"caption":pName[r],"startIndex":pIndex[r],"colSpan":pColspan[r]});
							}
						    pIndex[r] = i;
						    pColspan[r] = 1;
						} else if(pName[r] !== "") {
							pColspan[r] ++;
						}
						pName[r] = cName;
					} else {
						cns[r].push(cName);
					}
				} // for r				
			} //for i
			//最后一次处理
			for(var r = 0, rlen = pName.length; r < rlen - 1; r++) {
				if(pName[r] !== "") {
					cns[r].push({"caption":pName[r],"startIndex":pIndex[r],"colSpan":pColspan[r]});
				}
			}
			return {"colNames":cns,"colModels":cms};
		 },
		 /**
		  * 高亮显示.
		  */
		 setHeightLight:function() {
			 this.getOption().heightLight = true;
			 this.refresh();
			 this.getOption().heightLight = false;
		 },
		 /**
		  * 设置复选择状态.
		  */
		 setMultiSelect:function(state) {
             this.multiSelect = state === true;
             this.getOption().multiSelect = this.multiSelect;
             this.refreshTitle();
		 },
	     getFilterMark:function() {
	    	return this.dataSet.getFilterMark();
	     },
	     /**
	      * 获取当前节点.
	      */
	     getCurNode:function() {
	    	 return this.dataSet.getCurNode();
	     },
	     /**
	      * 获取父节点.
	      */
	     getParentNode:function(node) {
	    	 return this.dataSet.getParentNode(node); 
	     },
	     /**
	      * 获取子节点.
	      */
	     getChildNode:function(index, node) {
	    	 return this.dataSet.getChildNode(index, node);
	     },
	     /**
	      * 获取当前节点的数据.
	      */
	     getCurData:function(node) {
	    	 return this.dataSet.getCurData(node);
	     },
	     setFilterMark:function(res, callBack) {
	    	var me = this;
	    	this.dataSet.setFilterMark(res, function() {
	    		me.first();
	    		if(typeof callBack == "function") {
	    			callBack.apply(me);
	    		}
	    	});
	     },
	     /**
	      * 样式加载完成后，刷新一次.
	      */
	     doCssLoaded:function() {
	    	 this.refresh();
	     }
	});
	
	/**
	 * 表格控件.
	 */
	_bindRenderFunc("qzzquerygrid", qzz.ui.querygrid);

	return qzz.ui.querygrid;
});		